ProcessDirectoryRenaming() публичный статический Метод

Processes the renaming of a directory.
The method does not recurse in sub-directories.
public static ProcessDirectoryRenaming ( IFilesStorageProviderV30 provider, string oldName, string newName ) : bool
provider IFilesStorageProviderV30 The provider.
oldName string The old directory name (full path).
newName string The new directory name (full path).
Результат bool
Пример #1
0
        /// <summary>
        /// Recursively moves permissions from the old (renamed) directory to the new one.
        /// </summary>
        /// <param name="oldDirectory">The old directory name.</param>
        /// <param name="newDirectory">The new directory name.</param>
        private void MovePermissions(string oldDirectory, string newDirectory)
        {
            if (!oldDirectory.StartsWith("/"))
            {
                oldDirectory = "/" + oldDirectory;
            }
            if (!oldDirectory.EndsWith("/"))
            {
                oldDirectory = oldDirectory + "/";
            }
            if (!newDirectory.StartsWith("/"))
            {
                newDirectory = "/" + newDirectory;
            }
            if (!newDirectory.EndsWith("/"))
            {
                newDirectory = newDirectory + "/";
            }

            foreach (string sub in provider.ListDirectories(oldDirectory))
            {
                string subNew = newDirectory + sub.Substring(oldDirectory.Length);
                MovePermissions(sub, subNew);
            }

            AuthWriter.ClearEntriesForDirectory(provider, newDirectory);
            AuthWriter.ProcessDirectoryRenaming(provider, oldDirectory, newDirectory);
        }
Пример #2
0
        /// <summary>
        /// Recursively moves permissions from the old (renamed) directory to the new one.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="oldDirectory">The old directory.</param>
        /// <param name="newDirectory">The new directory.</param>
        private static void MovePermissions(IFilesStorageProviderV30 provider, string oldDirectory, string newDirectory)
        {
            oldDirectory = NormalizeFullPath(oldDirectory);
            newDirectory = NormalizeFullPath(newDirectory);

            // At this point the directory has been already renamed,
            // thus we must list on the new directory and construct the old name
            // Example: /directory/one/ renamed to /directory/two-two/
            // List on /directory/two-two/
            //     dir1
            //     dir2
            // oldSub = /directory/one/dir1/

            foreach (string sub in provider.ListDirectories(newDirectory))
            {
                string oldSub = oldDirectory + sub.Substring(newDirectory.Length);
                MovePermissions(provider, oldSub, sub);
            }

            AuthWriter.ClearEntriesForDirectory(provider, newDirectory);
            AuthWriter.ProcessDirectoryRenaming(provider, oldDirectory, newDirectory);
        }