Exemple #1
0
        public string UnlockFile(string userName, string currentDirectory, string fileName)
        {
            currentDirectory = NormalizeCurrentDirectory(currentDirectory);
            if (!PathUtils.IsAbsolutePath(fileName))
            {
                fileName = PathUtils.CombinePath(currentDirectory, fileName);
            }

            string[] directoryParts = PathUtils.SplitPath(fileName);

            IFileSystemItem currentItem = this.root;

            for (int i = 0; i < directoryParts.Length; i++)
            {
                currentItem = currentItem.ChildItems.FirstOrDefault(item => FileSystemItemNameComparer.Equals(item.Name, directoryParts[i]));
                if (currentItem is null)
                {
                    throw new FileSystemConsoleException("Destination path is not exists.");
                }
            }

            if (currentItem.Kind != FileSystemItemKind.File)
            {
                throw new FileSystemConsoleException("Destination path is not a file.");
            }

            currentItem.Unlock(userName);

            return(fileName);
        }