Dev2.PathOperations.Dev2ActivityIOBroker.ValidateRenameSourceAndDesinationTypes C# (CSharp) Method

ValidateRenameSourceAndDesinationTypes() private method

private ValidateRenameSourceAndDesinationTypes ( IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args ) : string
src IActivityIOOperationsEndPoint
dst IActivityIOOperationsEndPoint
args Dev2CRUDOperationTO
return string
        string ValidateRenameSourceAndDesinationTypes(IActivityIOOperationsEndPoint src,
                                                              IActivityIOOperationsEndPoint dst,
                                                              Dev2CRUDOperationTO args)
        {
            //ensures that the source and destination locations are of the same type
            if(src.PathIs(src.IOPath) != dst.PathIs(dst.IOPath))
            {
                throw new Exception("Source and destination need to be both files or directories");
            }

            //Rename Tool if the file/folder exists then delete it and put the source there
            if(dst.PathExist(dst.IOPath))
            {
                if(!args.Overwrite)
                {
                    throw new Exception("Destination directory already exists and overwrite is set to false");
                }

                //Clear the existing folder
                dst.Delete(dst.IOPath);
            }

            return Move(src, dst, args);
        }