Ejemplo n.º 1
0
        //prevent two loads at the same time.

        #region Methods

        public static ArchiveBase Load(Memory.Archive path, bool skipList = false)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                return(null);
            }
            lock (Locker)
            {
                if (CacheTryGetValue(path, out ArchiveBase value))
                {
                    return(value);
                }
                else
                {
                    value = new ArchiveZzz(path, skipList);
                    if (!value.IsOpen)
                    {
                        value = null;
                    }
                    if (value == null || string.IsNullOrWhiteSpace(path))
                    {
                        return(null);
                    }
                    if (CacheTryAdd(value.GetPath() ?? path, value))
                    {
                    }
                    path.SetFilename(value.GetPath() ?? path);
                }
                return(value);
            }
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }