Beispiel #1
0
        /// <summary>
        ///     Returns a readable stream of file data
        /// </summary>
        /// <param name="fileEntry">The file entry to load</param>
        /// <returns></returns>
        public Stream OpenFileStream(IArchiveFileEntry fileEntry, bool handleCompression = true)
        {
            Stream baseStream = null;

            baseStream = ArchiveFile.Open(fileEntry) ?? CoreDataArchive?.Open(fileEntry) ?? OpenLocalFile(fileEntry.Path);
            return(handleCompression ? HandleCompression(fileEntry, baseStream) : baseStream);
        }
Beispiel #2
0
        public static Archive FromFile(string name, ArchiveFile coreDataArchive = null)
        {
            string baseName;
            var    directory            = Path.GetDirectoryName(name);
            var    nameWithoutExtension = Path.GetFileNameWithoutExtension(name);

            if (!string.IsNullOrWhiteSpace(directory))
            {
                baseName = Path.Combine(directory, nameWithoutExtension);
            }
            else
            {
                baseName = nameWithoutExtension;
            }

            var indexFile = ArchiveFileBase.FromFile(Path.ChangeExtension(baseName, "index")) as IndexFile;

            if (indexFile == null)
            {
                throw new ArgumentException($"Could not find {name}");
            }
            var         archiveFileName = Path.ChangeExtension(baseName, "archive");
            ArchiveFile archiveFile     = null;

            if (File.Exists(archiveFileName))
            {
                archiveFile = ArchiveFileBase.FromFile(archiveFileName) as ArchiveFile;
            }
            return(new Archive(indexFile, archiveFile, coreDataArchive));
        }
Beispiel #3
0
 public Archive(IndexFile index, ArchiveFile archive, ArchiveFile coreDataArchive)
 {
     IndexFile       = index;
     ArchiveFile     = archive;
     CoreDataArchive = coreDataArchive;
 }
Beispiel #4
0
 public void Dispose()
 {
     IndexFile?.Dispose();
     ArchiveFile?.Dispose();
 }