コード例 #1
0
        private static void Add(InternalZipDirectory directory, ZipEntry entry)
        {
            var parts = entry.FileName.Split(PathSplit, StringSplitOptions.RemoveEmptyEntries);

            var mainDic = directory;

            for (var i = 0; i < parts.Length; i++)
            {
                if (i == parts.Length - 1)
                {
                    if (entry.IsDirectory)
                    {
                        mainDic          = mainDic.GetOrAdd(parts[i]);
                        mainDic.ZipEntry = entry;
                    }
                    else
                    {
                        mainDic.AddFile(entry);
                    }
                }
                else
                {
                    mainDic = mainDic.GetOrAdd(parts[i]);
                }
            }
        }
コード例 #2
0
 public InZipFile(IDirectory parentDirectory, string originalPath, ZipFile file, InternalZipDirectory directory,
                  ZipEntry?entry)
     : base(() => parentDirectory, originalPath, Path.GetFileName(entry?.FileName ?? string.Empty))
 {
     _file      = file;
     _directory = directory;
     _entry     = entry;
 }
コード例 #3
0
        internal InternalZipDirectory GetOrAdd(string name)
        {
            var dic = Directorys.FirstOrDefault(d => d.Name == name);

            if (dic != null)
            {
                return(dic);
            }
            dic = new InternalZipDirectory(name);
            Directorys.Add(dic);
            return(dic);
        }
コード例 #4
0
        public void Reload(string source)
        {
            if (SaveAfterDispose)
                _file?.Save();
            _file?.Dispose();

            if (!ZipFile.IsZipFile(source)) return;

            _file = ZipFile.Read(source);
            ResetDirectory(_file, InternalZipDirectory.ReadZipDirectory(_file));
            Reset(OriginalPath, null);
        }
コード例 #5
0
        public static InternalZipDirectory ReadZipDirectory(ZipFile?file)
        {
            var directory = new InternalZipDirectory(string.Empty);

            if (file == null)
            {
                return(directory);
            }

            foreach (var entry in file)
            {
                Add(directory, entry);
            }

            return(directory);
        }
コード例 #6
0
 public InZipFileSystem(ZipFile? file)
     : base(null, "zip::", InternalZipDirectory.ReadZipDirectory(file), file, string.Empty)
 {
     _file = file;
     SaveAfterDispose = true;
 }