Esempio n. 1
0
        private DirNode GetParentDir(RelPath dirPath)
        {
            var folders = dirPath.GetAncestorFolders();

            return GetNode(folders);
        }
Esempio n. 2
0
 public bool Remove(RelPath relPath)
 {
     try
     {
         DirNode node = GetNode(relPath.GetAncestorFolders());
         return node.Remove(relPath.FileName());
     }
     catch (KeyNotFoundException)
     {
         // Looks like its already removed.
         return false;
     }
 }
Esempio n. 3
0
        public FsObject<RelPath> GetObject(RelPath path)
        {
            var folders = path.GetAncestorFolders();
            DirNode current = GetNode(folders);
            Name fName = path.FileName();
            folders.Add(fName);

            FsFile<Name> fsFile;
            if (current.Files.TryGetValue(fName, out fsFile))
            {
                return fsFile.WithNewPath(RelPath.FromNames(folders));
            }

            return current.Directories[fName].FolderInfo.WithNewPath(RelPath.FromNames(folders));
        }
Esempio n. 4
0
        public void MoveDirectory(RelPath sourcePath, RelPath targetPath)
        {
            DirNode parent = GetParentDir(sourcePath);
            DirNode node = parent.RemoveDirNode(sourcePath.FileName());

            DirNode target = EnsureNode(targetPath.GetAncestorFolders());

            target.AddDirNode(targetPath.FileName(), node);
        }
Esempio n. 5
0
        public FsFile<RelPath> GetFile(RelPath path)
        {
            var folders = path.GetAncestorFolders();
            DirNode parent = GetNode(folders);

            Name fName = path.FileName();
            folders.Add(fName);
            return parent.Files[fName].WithNewPath(RelPath.FromNames(folders));
        }