Exemple #1
0
        public override ArchiveBase GetArchive(Memory.Archive archive)
        {
            if (archive == Memory.Archives.ZZZ_MAIN || archive == Memory.Archives.ZZZ_OTHER)
            {
                var zzz = archive.ZZZ;
                if (FindFile(ref zzz) <= -1 || string.IsNullOrWhiteSpace(zzz))
                {
                    return(null);
                }
                if (File.Exists(zzz))
                {
                    archive.SetFilename(zzz);
                }
                return(!CacheTryGetValue(archive, out var ab) ? ArchiveZzz.Load(zzz) : ab);
            }

            if (CacheTryGetValue(archive, out var value))
            {
                return(value);
            }
            GetArchive(archive, out var fI, out var fS, out StreamWithRangeValues fL);
            return(fI == null || fS == null || fL == null ||
                   fI.Length == 0 || fL.Length == 0
                ? null
                : new ArchiveWorker(archive, fI, fS, fL));
        }
Exemple #2
0
        public static ArchiveBase Load(Memory.Archive archive)
        {
            if (archive.IsDir)
            {
                return(ArchiveWorker.Load(archive));
            }

            if (archive.IsFile)
            {
                if (archive.IsFileArchive || archive.IsFileIndex || archive.IsFileList)
                {
                    var a = new Memory.Archive(Path.GetFileNameWithoutExtension(archive), Path.GetDirectoryName(archive));
                    return(ArchiveWorker.Load(a));
                }

                if (archive.IsZZZ)
                {
                    return(ArchiveZzz.Load(archive));
                }

                return(ArchiveWorker.Load(archive));
            }

            return(null);
        }
Exemple #3
0
        public static ArchiveBase Load(Memory.Archive path, bool skipList = false)
        {
            if (path.IsZZZ)
            {
                return(ArchiveZzz.Load(path, skipList));
            }
            if (CacheTryGetValue(path, out var value))
            {
                return(value);
            }

            value = new ArchiveWorker(path, skipList);
            if (!value.IsOpen)
            {
                value = null;
            }
            if (CacheTryAdd(path, value))
            {
            }
            return(value);
        }