예제 #1
0
        public static void SaveZipStreamFromBuffer(Stream aOutputStream, Compression.CNameBufferValue[] apFileBuffers, string password)
        {
            Crc32           crc32           = new Crc32();
            ZipOutputStream zipOutputStream = new ZipOutputStream(aOutputStream);

            zipOutputStream.SetLevel(7);
            if (!string.IsNullOrEmpty(password))
            {
                zipOutputStream.Password = password;
            }
            Compression.CNameBufferValue[] cNameBufferValueArray = apFileBuffers;
            for (int i = 0; i < (int)cNameBufferValueArray.Length; i++)
            {
                Compression.CNameBufferValue cNameBufferValue = cNameBufferValueArray[i];
                byte[]   bufferValue = cNameBufferValue.BufferValue;
                ZipEntry zipEntry    = new ZipEntry(cNameBufferValue.Name)
                {
                    DateTime = DateTime.Now,
                    Size     = (long)((int)bufferValue.Length)
                };
                crc32.Reset();
                crc32.Update(bufferValue);
                zipEntry.Crc = crc32.Value;
                zipOutputStream.PutNextEntry(zipEntry);
                zipOutputStream.Write(bufferValue, 0, (int)bufferValue.Length);
            }
            zipOutputStream.Finish();
            zipOutputStream.Close();
        }
예제 #2
0
 public static byte[] CompressStringBuffers(Compression.CNameStringValue[] apStrings, Encoding aEncoding, string password)
 {
     Compression.CNameBufferValue[] cNameBufferValueArray = new Compression.CNameBufferValue[(int)apStrings.Length];
     for (int i = 0; i < (int)apStrings.Length; i++)
     {
         Compression.CNameBufferValue cNameBufferValue = new Compression.CNameBufferValue(apStrings[i].Name, aEncoding.GetBytes(apStrings[i].StringValue));
         cNameBufferValueArray[i] = cNameBufferValue;
     }
     return(Compression.CompressBinaryBuffers(cNameBufferValueArray, password));
 }
예제 #3
0
        public static byte[] CompressStringBuffers(StringDictionaryByName apStrings, Encoding aEncoding)
        {
            int num = 0;

            Compression.CNameBufferValue[] cNameBufferValueArray = new Compression.CNameBufferValue[apStrings.Count];
            foreach (string key in apStrings.Keys)
            {
                Compression.CNameBufferValue cNameBufferValue = new Compression.CNameBufferValue(key, aEncoding.GetBytes(apStrings[key]));
                cNameBufferValueArray[num] = cNameBufferValue;
                num++;
            }
            return(Compression.CompressBinaryBuffers(cNameBufferValueArray));
        }
예제 #4
0
        public static void SaveZipFile(string sFileName, StringDictionaryByName apStrings, Encoding aEncoding)
        {
            int num = 0;

            Compression.CNameBufferValue[] cNameBufferValueArray = new Compression.CNameBufferValue[apStrings.Count];
            foreach (string key in apStrings.Keys)
            {
                Compression.CNameBufferValue cNameBufferValue = new Compression.CNameBufferValue(key, aEncoding.GetBytes(apStrings[key]));
                cNameBufferValueArray[num] = cNameBufferValue;
                num++;
            }
            Compression.SaveZipFileFromBuffer(sFileName, cNameBufferValueArray);
        }
예제 #5
0
        public static StringDictionaryByName ReadZipFileToStringDict(string sFileName, Encoding aEncoding)
        {
            Compression.CNameBufferValue[] buffer = Compression.ReadZipStreamToBuffer(File.OpenRead(sFileName));
            StringDictionaryByName         stringDictionaryByName = new StringDictionaryByName();

            Compression.CNameBufferValue[] cNameBufferValueArray = buffer;
            for (int i = 0; i < (int)cNameBufferValueArray.Length; i++)
            {
                Compression.CNameBufferValue cNameBufferValue = cNameBufferValueArray[i];
                stringDictionaryByName.Add(cNameBufferValue.Name, aEncoding.GetString(cNameBufferValue.BufferValue));
            }
            return(stringDictionaryByName);
        }
예제 #6
0
        public static StringDictionaryByName ReadZipBufferToStringDict(byte[] aoBuffer, Encoding aEncoding)
        {
            Compression.CNameBufferValue[] cNameBufferValueArray  = Compression.DecompressBinaryBuffers(aoBuffer);
            StringDictionaryByName         stringDictionaryByName = new StringDictionaryByName();

            Compression.CNameBufferValue[] cNameBufferValueArray1 = cNameBufferValueArray;
            for (int i = 0; i < (int)cNameBufferValueArray1.Length; i++)
            {
                Compression.CNameBufferValue cNameBufferValue = cNameBufferValueArray1[i];
                stringDictionaryByName.Add(cNameBufferValue.Name, aEncoding.GetString(cNameBufferValue.BufferValue));
            }
            return(stringDictionaryByName);
        }