Exemplo n.º 1
0
        protected override Result RenameDirectoryImpl(string oldPath, string newPath)
        {
            oldPath = PathTools.Normalize(oldPath);
            newPath = PathTools.Normalize(newPath);

            // Official FS behavior is to do nothing in this case
            if (oldPath == newPath)
            {
                return(Result.Success);
            }

            // FS does the subpath check before verifying the path exists
            if (PathTools.IsSubPath(oldPath.AsSpan(), newPath.AsSpan()))
            {
                ThrowHelper.ThrowResult(ResultFs.DestinationIsSubPathOfSource);
            }

            Result rc = GetDirInfo(out DirectoryInfo srcDir, ResolveLocalPath(oldPath));

            if (rc.IsFailure())
            {
                return(rc);
            }

            rc = GetDirInfo(out DirectoryInfo dstDir, ResolveLocalPath(newPath));
            if (rc.IsFailure())
            {
                return(rc);
            }

            return(RenameDirInternal(srcDir, dstDir));
        }