예제 #1
0
        public static Stream[] GetFileStreams(string fromZip, string password, int[] list)
        {
            using (FileStream fs = File.OpenRead(fromZip)) {
                BlubbZipFile blubb = new BlubbZipFile(fs);
                blubb.Password = password;

                Stream[] streams = new Stream[list.Length];
                int      counter = 0;
                foreach (int index in list)
                {
                    Stream s      = blubb.GetInputStream(index);
                    Stream writer = new MemoryStream();
                    byte[] data   = new byte[4096];
                    int    size   = s.Read(data, 0, data.Length);

                    while (size > 0)
                    {
                        writer.Write(data, 0, size);
                        size = s.Read(data, 0, data.Length);
                    }

                    streams[counter++] = writer;
                }
                blubb.Close();

                return(streams);
            }
        }
예제 #2
0
        public static Stream GetFileStream(string fromZip, string password, int index)
        {
            using (FileStream fs = File.OpenRead(fromZip)) {
                BlubbZipFile blubb = new BlubbZipFile(fs);
                blubb.Password = password;

                Stream s      = blubb.GetInputStream(index);
                Stream writer = new MemoryStream();
                byte[] data   = new byte[4096];
                int    size   = s.Read(data, 0, data.Length);

                while (size > 0)
                {
                    writer.Write(data, 0, size);
                    size = s.Read(data, 0, data.Length);
                }

                blubb.Close();
                return(writer);
            }
        }
예제 #3
0
        public static MemoryStream FetchFromFile(string blubbzipFilePath, string blubbzipPassword, int entryIndex)
        {
            using (FileStream fs = File.OpenRead(blubbzipFilePath)) {
                BlubbZipFile blubb = new BlubbZipFile(fs);
                blubb.Password = blubbzipPassword;

                Stream       s      = blubb.GetInputStream(entryIndex);
                MemoryStream Writer = new MemoryStream();
                byte[]       data   = new byte[4096];
                int          size   = s.Read(data, 0, data.Length);

                while (size > 0)
                {
                    Writer.Write(data, 0, size);
                    size = s.Read(data, 0, data.Length);
                }

                blubb.Close();
                return(Writer);
            }
        }
예제 #4
0
        public static void FetchAllFromFile(string fileName, string password, EBlubbZipHelperLoadType loadType, out Dictionary <int, Stream> streamList, out Dictionary <int, string> fileList, out Dictionary <int, BlubbZipEntry> entryList)
        {
            fileList   = new Dictionary <int, string>();
            streamList = new Dictionary <int, Stream>();
            entryList  = new Dictionary <int, BlubbZipEntry>();

            if (File.Exists(fileName) == false)
            {
                throw new Exception("File not Found!\n" + fileName);
            }

            using (FileStream fs = File.OpenRead(fileName)) {
                BlubbZipFile blubb = new BlubbZipFile(fs);
                blubb.Password = password;

                for (int cz = 0; cz < blubb.Count; cz++)
                {
                    if (blubb[cz].IsFile == false)
                    {
                        continue;
                    }
                    if ((loadType & EBlubbZipHelperLoadType.Streams) > 0)
                    {
                        streamList.Add(cz, blubb.GetInputStream(cz));
                    }
                    if ((loadType & EBlubbZipHelperLoadType.FileList) > 0)
                    {
                        fileList.Add(cz, blubb[cz].Name.ToString(CultureInfo.InvariantCulture).Replace("/", @"\"));
                    }
                    if ((loadType & EBlubbZipHelperLoadType.Entrys) > 0)
                    {
                        entryList.Add(cz, blubb[cz].Clone() as BlubbZipEntry);
                    }
                }

                blubb.Close();
            }
        }
예제 #5
0
        public static void FetchAllFromFile(string blubbzipFilePath, string blubbzipPassword, EFastBlubbZipLoadType loadType, out Dictionary <int, Stream> StreamList, out Dictionary <int, string> FileList, out Dictionary <int, BlubbZipEntry> EntryList)
        {
            FileList   = new Dictionary <int, string>();
            StreamList = new Dictionary <int, Stream>();
            EntryList  = new Dictionary <int, BlubbZipEntry>();

            if (File.Exists(blubbzipFilePath) == false)
            {
                throw new Exception("File not Found!\n" + blubbzipFilePath);
            }

            using (FileStream fs = File.OpenRead(blubbzipFilePath)) {
                BlubbZipFile blubb = new BlubbZipFile(fs);
                blubb.Password = blubbzipPassword;

                for (int cz = 0; cz < blubb.Count; cz++)
                {
                    if (blubb[cz].IsFile == false)
                    {
                        continue;
                    }
                    if ((loadType & EFastBlubbZipLoadType.Streams) > 0)
                    {
                        StreamList.Add(cz, blubb.GetInputStream(cz));
                    }
                    if ((loadType & EFastBlubbZipLoadType.FileList) > 0)
                    {
                        FileList.Add(cz, blubb[cz].Name.ToString().Replace("/", @"\"));
                    }
                    if ((loadType & EFastBlubbZipLoadType.Entrys) > 0)
                    {
                        EntryList.Add(cz, blubb[cz].Clone() as BlubbZipEntry);
                    }
                }

                blubb.Close();
            }
        }