public static IEnumerable <CacheBlockFileFileEntry> GetFileEntries(string directory, bool mixed) { if (directory is null) { throw new ArgumentNullException(nameof(directory)); } directory = IOHelpers.NormalizeDirectory(directory); if (!Directory.Exists(directory)) { throw new DirectoryNotFoundException($"Source directory '{directory}' does not exist."); } IEnumerable <string> files; if (mixed) { files = InitialCacheBlockDirectories .Select(a => Path.Combine(directory, a)) .Where(Directory.Exists) .SelectMany(a => Directory.EnumerateFiles(a, "*", SearchOption.AllDirectories)) ; } else { if (Directory.EnumerateFiles(directory, "*").Any()) { throw new IOException($"Source directory '{directory}' has files in it. It should only contain directories."); } files = Directory.EnumerateFiles(directory, "*", SearchOption.AllDirectories); } return(files.Select(a => CacheBlockFileFileEntry.FromExternalName(a.Substring(directory.Length)))); }
public CacheBlockReader(Stream stream) : base(stream) { var count = ReadHeader(); FileEntries = new CacheBlockFileFileEntry[count]; ReadFileEntries(); BaseOffset = stream.Position; }
private void ReadNames() { for (int i = 0; i < FileEntries.Length; i++) { var name = Stream.ReadLength32String(); FileEntries[i] = CacheBlockFileFileEntry.FromInternalName(name); } }