public IEnumerable <AbsoluteFilePath> GetFilesOf(AbsoluteFolderPath absoluteFolderPath) { Tree <DirectoryEntry> currentDirectory = this.GetDirectoryBy(absoluteFolderPath); EnsureDirectoryExists(currentDirectory, absoluteFolderPath); return(currentDirectory.Item.Files.Select(i => new AbsoluteFilePath(Path.Combine(absoluteFolderPath, i.Name))).ToList()); }
public IEnumerable <AbsoluteFilePath> GetFilesOfRecursive(AbsoluteFolderPath absoluteFolderPath) { Tree <DirectoryEntry> currentDirectory = this.GetDirectoryBy(absoluteFolderPath); EnsureDirectoryExists(currentDirectory, absoluteFolderPath); return(this.GetFilesOfRecursiveInternal(absoluteFolderPath, currentDirectory)); }
public IEnumerable <AbsoluteFilePath> GetFilesOfRecursive(AbsoluteFolderPath absoluteFolderPath) { var currentItem = this.GetDirectoryBy(absoluteFolderPath); EnsureDirectoryExists(currentItem, absoluteFolderPath); return(this.GetFilesOfRecursiveInternal(absoluteFolderPath, currentItem)); }
public IEnumerable <AbsoluteFolderPath> GetSubdirectoriesOf(AbsoluteFolderPath absoluteFolderPath) { var currentItem = this.GetDirectoryBy(absoluteFolderPath); EnsureDirectoryExists(currentItem, absoluteFolderPath); return(currentItem.Children.Select(i => new AbsoluteFolderPath(Path.Combine(absoluteFolderPath, i.Item.Name))).ToList()); }
public void DeleteDirectory(AbsoluteFolderPath absoluteFolderPath) { var directoryEntryToDelete = this.GetDirectoryBy(absoluteFolderPath); EnsureDirectoryExists(directoryEntryToDelete, absoluteFolderPath); var parentDirectory = this.GetDirectoryBy(Directory.GetParent(absoluteFolderPath).FullName); RemoveDirectoryEntry(parentDirectory, directoryEntryToDelete); }
public void Move(AbsoluteFilePath absoluteSourceFilePath, AbsoluteFilePath absoluteDestinationFilePath) { IEnumerable <byte> contents = this.GetFile(absoluteSourceFilePath); AbsoluteFolderPath absoluteDestinationFolderPath = Path.GetDirectoryName(absoluteDestinationFilePath); this.CreateDirectory(absoluteDestinationFolderPath); this.AddFile(absoluteDestinationFilePath, contents); this.DeleteFile(absoluteSourceFilePath); }
private IEnumerable <AbsoluteFilePath> GetFilesOfRecursiveInternal(AbsoluteFolderPath absoluteFolderPath, Tree <DirectoryEntry> directoryEntry) { List <AbsoluteFilePath> files = directoryEntry.Item.Files.Select(i => new AbsoluteFilePath(Path.Combine(absoluteFolderPath, i.Name))).ToList(); foreach (Tree <DirectoryEntry> child in directoryEntry.Children) { IEnumerable <AbsoluteFilePath> filesInChild = this.GetFilesOfRecursiveInternal(Path.Combine(absoluteFolderPath, child.Item.Name), child); files.AddRange(filesInChild); } return(files); }
public void Copy(AbsoluteFilePath absoluteSourceFilePath, AbsoluteFilePath absoluteDestinationFilePath, bool overwrite) { IEnumerable <byte> contents = this.GetFile(absoluteSourceFilePath); if (!overwrite && this.FileExists(absoluteDestinationFilePath)) { throw new IOException(string.Format("The file '{0}' already exists.", absoluteDestinationFilePath)); } AbsoluteFolderPath absoluteDestinationFolderPath = Path.GetDirectoryName(absoluteDestinationFilePath); this.CreateDirectory(absoluteDestinationFolderPath); this.AddFile(absoluteDestinationFilePath, contents); }
private IEnumerable <AbsoluteFolderPath> GetSubdirectoriesOfRecursiveInternal(AbsoluteFolderPath absoluteFolderPath, Tree <DirectoryEntry> directoryEntry) { List <AbsoluteFolderPath> directories = directoryEntry.Children.Select(d => new AbsoluteFolderPath(Path.Combine(absoluteFolderPath, d.Item.Name))).ToList(); foreach (Tree <DirectoryEntry> child in directoryEntry.Children) { IEnumerable <AbsoluteFolderPath> subFoldersOfChild = this.GetSubdirectoriesOfRecursiveInternal(Path.Combine(absoluteFolderPath, child.Item.Name), child); directories.AddRange(subFoldersOfChild); } return(directories); }
public void CreateDirectory(AbsoluteFolderPath absoluteFolderPath) { this.CreateDirectoryWith(absoluteFolderPath); }
public bool DirectoryExists(AbsoluteFolderPath absoluteFolderPath) { return(this.GetDirectoryBy(absoluteFolderPath) != null); }
//NB: extend this partial class with well know folders such as: // public IFolder TempStorage { get; private set; } public IFolder CreateFolder(AbsoluteFolderPath path) { Directory.CreateDirectory(path); return(new SpotFolder(path)); }
public IFolder GetFolder(AbsoluteFolderPath path) { return(Directory.Exists(path) ? new SpotFolder(path) : null); }
public IFolder GetFolder(AbsoluteFolderPath path) { throw new NotImplementedException("RamFileSystem.GetFolder"); }
public SpotFolder(AbsoluteFolderPath path) { _path = path; }