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; } }
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)); }
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); }
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)); }