示例#1
0
        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());
        }
示例#2
0
        public IEnumerable <AbsoluteFilePath> GetFilesOfRecursive(AbsoluteFolderPath absoluteFolderPath)
        {
            Tree <DirectoryEntry> currentDirectory = this.GetDirectoryBy(absoluteFolderPath);

            EnsureDirectoryExists(currentDirectory, absoluteFolderPath);

            return(this.GetFilesOfRecursiveInternal(absoluteFolderPath, currentDirectory));
        }
示例#3
0
        public IEnumerable <AbsoluteFilePath> GetFilesOfRecursive(AbsoluteFolderPath absoluteFolderPath)
        {
            var currentItem = this.GetDirectoryBy(absoluteFolderPath);

            EnsureDirectoryExists(currentItem, absoluteFolderPath);

            return(this.GetFilesOfRecursiveInternal(absoluteFolderPath, currentItem));
        }
示例#4
0
        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());
        }
示例#5
0
        public void DeleteDirectory(AbsoluteFolderPath absoluteFolderPath)
        {
            var directoryEntryToDelete = this.GetDirectoryBy(absoluteFolderPath);

            EnsureDirectoryExists(directoryEntryToDelete, absoluteFolderPath);

            var parentDirectory = this.GetDirectoryBy(Directory.GetParent(absoluteFolderPath).FullName);

            RemoveDirectoryEntry(parentDirectory, directoryEntryToDelete);
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#10
0
 public void CreateDirectory(AbsoluteFolderPath absoluteFolderPath)
 {
     this.CreateDirectoryWith(absoluteFolderPath);
 }
示例#11
0
 public bool DirectoryExists(AbsoluteFolderPath absoluteFolderPath)
 {
     return(this.GetDirectoryBy(absoluteFolderPath) != null);
 }
示例#12
0
        //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));
        }
示例#13
0
 public IFolder GetFolder(AbsoluteFolderPath path)
 {
     return(Directory.Exists(path) ? new SpotFolder(path) : null);
 }
示例#14
0
 public IFolder GetFolder(AbsoluteFolderPath path)
 {
     throw new NotImplementedException("RamFileSystem.GetFolder");
 }
示例#15
0
 public SpotFolder(AbsoluteFolderPath path)
 {
     _path = path;
 }