Example #1
0
        private void addParentDirectories(HashSet <String> foundDirectories, ZipFileInfo fileInfo)
        {
            ZipFileInfo currentInfo      = fileInfo;
            String      currentDirectory = currentInfo.DirectoryName;
            int         lastIndex        = currentDirectory.LastIndexOf('/', currentDirectory.Length - 1);

            while (lastIndex != -1)
            {
                currentDirectory = currentDirectory.Substring(0, lastIndex + 1);
                if (!foundDirectories.Contains(currentDirectory))
                {
                    directories.Add(new ZipFileInfo(currentDirectory, 0, 0));
                    foundDirectories.Add(currentDirectory);
                    lastIndex = currentDirectory.LastIndexOf('/', currentDirectory.Length - 2);
                }
                else
                {
                    lastIndex = -1;
                }
            }
        }
Example #2
0
        private unsafe void commonLoad()
        {
            pooledZzipDirHandles             = new LifecycleObjectPool <PooledZzipDir>(() => new PooledZzipDir(file), dir => dir.Dispose());
            pooledZzipDirHandles.MaxPoolSize = 3;
            PooledZzipDir zzipDir = pooledZzipDirHandles.getPooledObject();

            HashSet <String> foundDirectories = new HashSet <string>();

            //Read the directories and files out of the zip file
            ZZipStat zzipEntry = new ZZipStat();

            while (ZipFile_Read(zzipDir.Ptr, &zzipEntry))
            {
                String entryName = zzipEntry.Name;
                if (fileFilter == null || entryName.StartsWith(fileFilter))
                {
                    ZipFileInfo fileInfo = new ZipFileInfo(entryName, zzipEntry.CompressedSize, zzipEntry.UncompressedSize);
                    //Make sure we don't end with a /
                    if (fileInfo.IsDirectory)
                    {
                        if (!foundDirectories.Contains(fileInfo.FullName))
                        {
                            directories.Add(fileInfo);
                            foundDirectories.Add(fileInfo.FullName);
                        }
                    }
                    else
                    {
                        files.Add(fileInfo);
                    }
                    addParentDirectories(foundDirectories, fileInfo);
                }
            }

            zzipDir.finished();
        }