Esempio n. 1
0
        public IFileSystem Generate(ZipFile zipFile, IDictionary <string, int> fileTypes)
        {
            _root = P4kDirectory.Root();

            var files = new List <IFile>();

            foreach (ZipEntry item in zipFile.Cast <ZipEntry>()
                     .Where(f => f.IsFile))
            {
                var directory = EnsureDirectoryExists(item.Name);
                var file      = new P4kFile(item, zipFile);

                files.Add(file);
                directory.Add(file);

                // statistics
                var extension = Path.GetExtension(file.Name)
                                .TrimStart('.');

                if (!fileTypes.ContainsKey(extension))
                {
                    fileTypes.Add(extension, 1);
                }
                else
                {
                    fileTypes[extension]++;
                }
            }

            return(new P4kFileSystem(_root, Convert.ToInt32(zipFile.Count), files));
        }
Esempio n. 2
0
        public IFileSystem Generate(ZipFile zipFile)
        {
            _root = P4kDirectory.Root();
            foreach (ZipEntry item in zipFile.Cast <ZipEntry>()
                     .Where(f => f.IsFile))
            {
                var directory = EnsureDirectoryExists(item.Name);
                directory.Add(new P4kFile(item, zipFile));
            }

            return(new P4kFileSystem(_root));
        }