public VirtualFileStorageDriver(VirtualFileStorage storage, VirtualFileStorageDriver parent, string rootPath) { Storage = storage; Parent = parent; RootPath = rootPath; Storage.AddDriver(this); }
public IEnumerable <string> EnumerateFiles(string fullDirectoryPath) { if (String.IsNullOrWhiteSpace(fullDirectoryPath)) { throw new ArgumentException(); } fullDirectoryPath = FileUtil.NormalizePathSeparator(fullDirectoryPath, true); VirtualFileStorageDriver closestDriver = FindClosestDriver(fullDirectoryPath); return(closestDriver.EnumerateFiles(fullDirectoryPath.Substring(closestDriver.RootPath.Length))); }
public override Stream OpenRead(string relativePath) { if (File.Exists(relativePath)) { return(DoOpen(relativePath, FileAccess.Read)); } VirtualFileStorageDriver d = FindDriverForPath(relativePath); if (d != null) { return(d.OpenRead(relativePath.Substring(d.RootPath.Length))); } throw new FileNotFoundException("File not found.", RootPath + relativePath); }
IEnumerable <string> EnumerateFilesForExistingDirectory(string relativePath) { foreach (string f in Directory.EnumerateFiles(relativePath, "*", SearchOption.AllDirectories)) { yield return(f); VirtualFileStorageDriver d = CreateDriver(f); if (d != null) { foreach (string fInZip in d.EnumerateFiles(String.Empty)) { yield return(fInZip); } } } }
private VirtualFileStorageDriver FindDriverForPath(string relativePath) { VirtualFileStorageDriver d = null; string containerPath = relativePath; while ((containerPath = Path.GetDirectoryName(containerPath)) != null) { if (File.Exists(containerPath)) { d = CreateDriver(containerPath); if (d != null) { break; } } } return(d); }
public Stream OpenRead(string fullPath) { if (String.IsNullOrWhiteSpace(fullPath)) { throw new ArgumentException(); } fullPath = FileUtil.NormalizePathSeparator(fullPath, false); // Early test: if it is a file, we shortcut the process. if (File.Exists(fullPath)) { return(_root.DoOpen(fullPath, FileAccess.Read)); } VirtualFileStorageDriver closestDriver = FindClosestDriver(fullPath); return(closestDriver.OpenRead(fullPath.Substring(closestDriver.RootPath.Length))); }
public override IEnumerable <string> EnumerateFiles(string relativePath) { if (Directory.Exists(relativePath)) { return(EnumerateFilesForExistingDirectory(relativePath)); } VirtualFileStorageDriver d = CreateDriver(relativePath); if (d != null) { return(d.EnumerateFiles(String.Empty)); } d = FindDriverForPath(relativePath); if (d != null) { return(d.EnumerateFiles(relativePath.Substring(d.RootPath.Length))); } throw new DirectoryNotFoundException(String.Format("Directory not found: {0}", relativePath)); }
internal VirtualFileStorageDriver(VirtualFileStorage storage) { Storage = storage; Parent = null; RootPath = String.Empty; }
public VirtualFileStorageDriverRootZip(VirtualFileStorage storage, VirtualFileStorageDriver parent, string rootPath) : base(storage, parent, rootPath) { Debug.Assert(rootPath.EndsWith("\\")); _file = new ZipArchive(File.OpenRead(rootPath.Substring(0, rootPath.Length - 1))); }
internal void AddDriver(VirtualFileStorageDriver d) { _drivers.Add(d); }