Exemplo n.º 1
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;
     }
 }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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));
        }