コード例 #1
0
ファイル: LevelDBInterop.cs プロジェクト: luchaoshuai/Aoite
        static string LoadLevelDB()
        {
            var  bitName   = "x32";
            long dllLength = 410624;

            if (Environment.Is64BitProcess)
            {
                bitName   = "x64";
                dllLength = 491520;
            }
            var folder = Path.Combine(GA.TempFolder, DLL_NAME_SIMPLE, bitName);

            GA.IO.CreateDirectory(folder);
            var dllFile = new FileInfo(Path.Combine(folder, DLL_NAME));

            if (!dllFile.Exists || dllFile.Length != dllLength)
            {
                using (var stream = typeof(LDB).Assembly.GetManifestResourceStream("Aoite.LevelDB.Interop." + DLL_NAME_SIMPLE + bitName + ".gz"))
                {
                    using (var gzipStream = new System.IO.Compression.GZipStream(stream, System.IO.Compression.CompressionMode.Decompress))
                    {
                        using (var fileStream = dllFile.Create())
                        {
                            gzipStream.CopyTo(fileStream);
                        }
                    }
                }
            }
            return(dllFile.FullName);
        }
コード例 #2
0
ファイル: Svg.cs プロジェクト: Monkeybin11/Draw2D
        public SKPicture Load(string path)
        {
            Reset();
            var extension = System.IO.Path.GetExtension(path);

            switch (extension.ToLower())
            {
            default:
            case ".svg":
            {
                var svgDocument = SvgDocument.Open <SvgDocument>(path, null);
                if (svgDocument != null)
                {
                    svgDocument.FlushStyles(true);
                    Picture  = Load(svgDocument);
                    Document = svgDocument;
                    return(Picture);
                }
                return(null);
            }

            case ".svgz":
            {
                using (var fileStream = System.IO.File.OpenRead(path))
                    using (var gzipStream = new System.IO.Compression.GZipStream(fileStream, System.IO.Compression.CompressionMode.Decompress))
                        using (var memoryStream = new System.IO.MemoryStream())
                        {
                            gzipStream.CopyTo(memoryStream);
                            memoryStream.Position = 0;
                            return(Load(memoryStream));
                        }
            }
            }
        }
コード例 #3
0
        /// <summary>
        /// Uncompress a string to a UTF8-8 string
        /// </summary>
        /// <param name="bytes"></param>
        /// <returns></returns>
        public static string Uncompress(this byte[] bytes)
        {
            using (var mso = new MemoryStream())
            {
                MemoryStream msi = null;
                try
                {
                    msi = new MemoryStream(bytes);
                    using (var gs = new System.IO.Compression.GZipStream(msi, System.IO.Compression.CompressionMode.Decompress, true))
                    {
                        msi = null;
                        gs.CopyTo(mso);
                    }
                }
                finally
                {
                    if (msi != null)
                    {
                        msi.Dispose();
                    }
                }

                return(Encoding.UTF8.GetString(mso.ToArray()));
            }
        }
コード例 #4
0
        internal static System.IO.FileInfo DecompressGZip(System.IO.FileInfo CompressedFile)
        {
            // Get the stream of the source file.
            using (System.IO.FileStream inFile = CompressedFile.OpenRead())
            {
                // Get original file extension, for example
                // "doc" from report.doc.gz.
                string curFile  = CompressedFile.FullName;
                string origName = curFile.Remove(curFile.Length -
                                                 CompressedFile.Extension.Length);

                //Create the decompressed file.
                using (System.IO.FileStream outFile = System.IO.File.Create(origName))
                {
                    using (System.IO.Compression.GZipStream Decompress = new System.IO.Compression.GZipStream(inFile,
                                                                                                              System.IO.Compression.CompressionMode.Decompress))
                    {
                        // Copy the decompression stream
                        // into the output file.
                        Decompress.CopyTo(outFile);
                    }
                }
                return(new System.IO.FileInfo(origName));
            }
        }
コード例 #5
0
        public static Data GzJsonDeSerialize(string fileName, Action <Exception> toLog = null)
        {
            if (System.IO.File.Exists(fileName) == false)
            {
                return(null);
            }
            Data result = null;

            try
            {
                using (System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
                    using (System.IO.Compression.GZipStream gz = new System.IO.Compression.GZipStream(fs, System.IO.Compression.CompressionMode.Decompress, false))
                        using (System.IO.MemoryStream mso = new System.IO.MemoryStream())
                        {
                            gz.CopyTo(mso);
                            DataSize     = mso.Length;
                            mso.Position = 0;
                            var serializer = new DataContractJsonSerializer(typeof(Data));
                            result = (Data)serializer.ReadObject(mso);
                        }
            }
            catch (Exception ex) { if (toLog != null)
                                   {
                                       toLog(ex);
                                   }
                                   else
                                   {
                                       throw ex;
                                   } return(null); }
            return(result);
        }
コード例 #6
0
ファイル: GZipCompression.cs プロジェクト: hnjm/SimpleSockets
        /// <summary>
        /// Decompresses a file
        /// </summary>
        /// <param name="fileToDecompress"></param>
        /// <param name="outputPath"></param>
        public FileInfo Decompress(FileInfo fileToDecompress, FileInfo outputfile)
        {
            try
            {
                using (var originalFileStream = fileToDecompress.OpenRead())
                {
                    if ((System.IO.File.GetAttributes(fileToDecompress.FullName) & FileAttributes.Hidden) != FileAttributes.Hidden)
                    {
                        if (string.IsNullOrEmpty(outputfile.FullName) || outputfile.Exists)
                        {
                            throw new Exception("File already exists.");
                        }

                        using (var decompressedFileStream = outputfile?.Create())
                        {
                            using (var decompressionStream = new System.IO.Compression.GZipStream(originalFileStream, System.IO.Compression.CompressionMode.Decompress))
                            {
                                decompressionStream.CopyTo(decompressedFileStream);
                            }

                            return(outputfile);
                        }
                    }

                    throw new Exception("The file cannot be decompressed.");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
コード例 #7
0
        public void SetData(string str, string scv, byte[] dealsInfo, byte[] dealsData)
        {
            this.CurrentTestRet    = WekaUtils.StringToDoubleArray(str);
            this.CurrentClassValue = WekaUtils.StringToDoubleArray(scv);

            var deals = Feng.Windows.Utils.SerializeHelper.Deserialize <DealsInfo>(dealsInfo);

            if (dealsData != null)
            {
                System.IO.MemoryStream outStream = new System.IO.MemoryStream();
                var inStream = new System.IO.MemoryStream(dealsData);
                System.IO.Compression.GZipStream zipStream = new System.IO.Compression.GZipStream(inStream, System.IO.Compression.CompressionMode.Decompress);
                zipStream.CopyTo(outStream);

                deals.Deals = Feng.Windows.Utils.SerializeHelper.Deserialize <List <DealInfo> >(outStream.ToArray());
            }
            else
            {
                deals.Deals = new List <DealInfo>();
            }
            if (deals != null)
            {
                this.Deals  = deals;
                Initialized = true;
            }
        }
コード例 #8
0
        private IEnumerable <VersionDescription> ParseResponse(WebHeaderCollection header, byte[] body)
        {
            switch (header.Get("Content-Encoding"))
            {
            case "gzip":
                using (var dst = new System.IO.MemoryStream())
                    using (var s = new System.IO.Compression.GZipStream(new System.IO.MemoryStream(body), System.IO.Compression.CompressionMode.Decompress)) {
                        s.CopyTo(dst);
                        dst.Flush();
                        body = dst.ToArray();
                    }
                break;

            case "deflate":
                using (var dst = new System.IO.MemoryStream())
                    using (var s = new System.IO.Compression.DeflateStream(new System.IO.MemoryStream(body), System.IO.Compression.CompressionMode.Decompress)) {
                        s.CopyTo(dst);
                        dst.Flush();
                        body = dst.ToArray();
                    }
                break;

            default:
                break;
            }
            return(ParseAppCast(System.Text.Encoding.UTF8.GetString(body)));
        }
コード例 #9
0
ファイル: compressv1.cs プロジェクト: nGenieDeveloper/BD2
 public override byte[] Encode(byte[] Input)
 {
     System.IO.Compression.GZipStream gzs = new System.IO.Compression.GZipStream(new System.IO.MemoryStream(Input), System.IO.Compression.CompressionMode.Compress);
     System.IO.MemoryStream           RMS /*i didn't mean it, it happend*/ = new System.IO.MemoryStream(Input.Length >> 1);
     RMS.WriteByte(0);
     gzs.CopyTo(RMS);
     return(RMS.ToArray());
 }
コード例 #10
0
 private void UncompressedFile(string compressedFile, string uncompressedFile)
 {
     using (System.IO.Compression.GZipStream compressed = new System.IO.Compression.GZipStream(new FileStream(compressedFile, FileMode.Open, FileAccess.Read), System.IO.Compression.CompressionMode.Decompress))
         using (FileStream uncompressed = new FileStream(uncompressedFile, FileMode.Create, FileAccess.Write))
         {
             compressed.CopyTo(uncompressed);
         }
 }
コード例 #11
0
 /// <summary>
 /// Decode the content
 /// </summary>
 /// <param name="data">Content to decode</param>
 /// <returns>Decoded content</returns>
 public byte[] Decode(byte[] data)
 {
     var output = new MemoryStream();
     var input = new MemoryStream(data);
     using (var stream = new System.IO.Compression.GZipStream(input, System.IO.Compression.CompressionMode.Decompress))
         stream.CopyTo(output);
     return output.ToArray();
 }
コード例 #12
0
        public override void OnLoad()
        {
            if (!Directory.Exists(PluginDataDirectory))
            {
                Directory.CreateDirectory(PluginDataDirectory);
            }
            if (!Directory.Exists(PluginDataDirectory + "\\Rift Teams"))
            {
                Directory.CreateDirectory(PluginDataDirectory + "\\Rift Teams");
            }
            if (!Directory.Exists(PluginDataDirectory + "\\Rift Teams\\Archive"))
            {
                Directory.CreateDirectory(PluginDataDirectory + "\\Rift Teams\\Archive");
            }

            if (File.Exists(PluginDataDirectory + "\\allMons.gz"))
            {
                using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(PluginDataDirectory + "\\allMons.gz")))
                {
                    using (System.IO.Compression.GZipStream gz = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Decompress))
                    {
                        using (MemoryStream os = new MemoryStream())
                        {
                            gz.CopyTo(os);
                            var ostr = Encoding.ASCII.GetString(os.ToArray());
                            allMons = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <ulong, KeyValuePair <RiftDeck, Monster> > > >(ostr);
                        }
                    }
                }
                foreach (var m in allMons.SelectMany(q => q.Value.Select(r => r.Value.Value)))
                {
                    var tid = long.Parse(m.MonsterTypeId.ToString().Substring(0, m.MonsterTypeId.ToString().Length - 2) + "1" + m.MonsterTypeId.ToString().Last());
                    m.Name = MonsterName(tid);

                    foreach (var r in m.Runes)
                    {
                        r.PrebuildAttributes();
                        m.ApplyRune(r);
                        r.AssignedName = m.Name;
                        r.Assigned     = m;
                    }
                }
            }
            if (File.Exists(PluginDataDirectory + "\\matchCount.json"))
            {
                matchCount = JsonConvert.DeserializeObject <Dictionary <RiftDungeon, Dictionary <string, Dictionary <string, int> > > >(File.ReadAllText(PluginDataDirectory + "\\matchCount.json"));
            }

            var files = Directory.GetFiles(PluginDataDirectory + "\\Rift Teams", "*.json");

            foreach (var f in files)
            {
                ProcessDeck(File.ReadAllText(f));
                File.Move(f, PluginDataDirectory + "\\Rift Teams\\Archive\\" + new FileInfo(f).Name);
            }
            loading = false;
            SaveStuff();
        }
コード例 #13
0
        /// <summary>
        /// Decode the content
        /// </summary>
        /// <param name="data">Content to decode</param>
        /// <returns>Decoded content</returns>
        public byte[] Decode(byte[] data)
        {
            var output = new MemoryStream();
            var input  = new MemoryStream(data);

            using (var stream = new System.IO.Compression.GZipStream(input, System.IO.Compression.CompressionMode.Decompress))
                stream.CopyTo(output);
            return(output.ToArray());
        }
コード例 #14
0
ファイル: PackageFile.cs プロジェクト: thbin/TraceLab
 private static void DecompressStream(System.IO.Stream inFile, System.IO.Stream outFile)
 {
     using (System.IO.Compression.GZipStream Decompress = new System.IO.Compression.GZipStream(inFile, System.IO.Compression.CompressionMode.Decompress, true))
     {
         // Copy the decompression stream
         // into the output file.
         Decompress.CopyTo(outFile);
     }
 }
コード例 #15
0
ファイル: Index (copy).cs プロジェクト: radtek/BackO
        internal void Open(long taskId)
        {
            this.Name     = "t" + taskId + ".idx";
            this.FullName = Path.Combine(Utilities.ConfigManager.GetValue("Backups.IndexFolder"), this.Name);
            if (!File.Exists(FullName))
            {
                throw new Exception("This index doesn't exists or doesn't have a local copy");
            }
            indexDbConn = new SqliteConnection();
            //indexDbConn.ConnectionString = "Version=3;Synchronous=off;Compress=True;data source=file:"+this.FullName;
            indexDbConn.ConnectionString = "Version=3,Synchronous=off,data source=file:" + this.FullName + "";
            indexDbConn.Open();
            dataFormatter = new BinaryFormatter();
            dataMs        = new MemoryStream();

            //get Header
            string headerQ = "SELECT data FROM header";

            System.Data.IDbCommand headerC = indexDbConn.CreateCommand();
            headerC.CommandText = headerQ;
            System.Data.IDataReader hReader = headerC.ExecuteReader();
            hReader.Read();
            dataMs = new MemoryStream();
            long dataSize = hReader.GetBytes(0, 0, null, 0, 0);
            int  offset = 0, bytesRead = 0;

            byte[] buffer = new byte[dataSize];
            //Console.WriteLine ("open() read="+hReader.GetBytes(0, 0, buffer, offset, BUFFER_SIZE));

            /*while((bytesRead = (int)hReader.GetBytes(0, offset, buffer, 0, 100)) > 0) {
             *      Console.WriteLine("open() read header : read="+bytesRead+", offset="+offset);
             *  dataMs.Write(buffer, 0, bytesRead);
             *  offset += bytesRead;
             *
             * }*/
            int curPos = 0;

            while (bytesRead < dataSize)
            {
                bytesRead += (int)hReader.GetBytes(0, curPos, buffer, curPos, (int)dataSize);
                curPos    += bytesRead;
            }
            dataMs.Write(buffer, 0, bytesRead);
            dataMs.Flush();
            //MemoryStream gzMs = new MemoryStream();
            dataMs.Position = 0;
            using (MemoryStream uncompressedStream = new MemoryStream()){
                using (gz = new System.IO.Compression.GZipStream(dataMs, System.IO.Compression.CompressionMode.Decompress, true)){
                    gz.CopyTo(uncompressedStream);
                }
                uncompressedStream.Position = 0;
                this.Header = (IndexHeader)dataFormatter.Deserialize(uncompressedStream);
            }

            dataMs.SetLength(0);
        }
コード例 #16
0
 static public byte[] DecompressGzip(byte[] compressed)
 {
     using (var decompressStream = new System.IO.Compression.GZipStream(
                new System.IO.MemoryStream(compressed), System.IO.Compression.CompressionMode.Decompress))
     {
         var decompressedStream = new System.IO.MemoryStream();
         decompressStream.CopyTo(decompressedStream);
         return(decompressedStream.ToArray());
     }
 }
コード例 #17
0
        internal dynamic GetObjectResponse(IInternetServiceListener Listener = null)
        {
            IHttpWebResponse response = GetResponse(Listener);
            if (response == null)
                return null;

            HttpStatusCode sc = response.StatusCode;

            if (sc != HttpStatusCode.OK)
            {
                if (Listener != null)
                    Listener.OnStatusCodeKO(sc);

                return null;
            }

            Stream readStream = response.GetResponseStream();
            if (readStream == null)
            {
                if (Listener != null)
                    Listener.OnUnExpectedUnreadableResult();

                return null;
            }

            Stream toberead = null;

            if (response.ContentEncoding == "gzip")
            {
                toberead = new MemoryStream();

                using (Stream unzip = new System.IO.Compression.GZipStream(readStream, System.IO.Compression.CompressionMode.Decompress))
                {
                    unzip.CopyTo(toberead); 
                }

                toberead.Position = 0;
                readStream.Dispose();
            }
            else
                toberead = readStream;


            string sr = null;
            using (toberead)
            {
                using (StreamReader reader = new StreamReader(toberead))
                {
                    sr = reader.ReadToEnd();
                }

            }

            return DynamicJsonConverter.DynamicDeSerialize(sr);
        }
コード例 #18
0
 public static byte[] DecompressGzip(byte[] gzip_data)
 {
     using (var stream = new System.IO.Compression.GZipStream(new MemoryStream(gzip_data), System.IO.Compression.CompressionMode.Decompress))
     {
         using (MemoryStream memory = new MemoryStream())
         {
             stream.CopyTo(memory);
             return(memory.ToArray());
         }
     }
 }
コード例 #19
0
ファイル: Utilities.cs プロジェクト: thirunjuguna/emby
 /// <summary>
 /// Decompress data using GZip
 /// </summary>
 /// <param name="dataToDecompress">The stream that hold the data</param>
 /// <returns>Bytes array of decompressed data</returns>
 public static byte[] Decompress(Stream dataToDecompress)
 {
     using (MemoryStream target = new MemoryStream())
     {
         using (System.IO.Compression.GZipStream decompressionStream = new System.IO.Compression.GZipStream(dataToDecompress, System.IO.Compression.CompressionMode.Decompress))
         {
             decompressionStream.CopyTo(target);
         }
         return(target.ToArray());
     }
 }
コード例 #20
0
        /// <summary>
        /// Unzips the specified zipped bytes using an in-memory GZipStream.
        /// </summary>
        /// <param name="zippedBytes">The zipped bytes to unzip.</param>
        /// <param name="encoding">The Encoding to use to parse the bytes.  Defaults to ASCII</param>
        /// <returns></returns>
        public static string Unzip(this byte[] zippedBytes, Encoding encoding = null)
        {
            using (var zipped = new MemoryStream(zippedBytes))
                using (var unzipper = new System.IO.Compression.GZipStream(zipped, System.IO.Compression.CompressionMode.Decompress))
                    using (var unzippedBytes = new MemoryStream())
                    {
                        unzipper.CopyTo(unzippedBytes);

                        encoding = encoding ?? Encoding.ASCII;
                        return(encoding.GetString(unzippedBytes.ToArray()));
                    }
        }
コード例 #21
0
ファイル: StringHelper.cs プロジェクト: JordanFisher/WAL
 public static byte[] Explode(this byte[] compressedBytes)
 {
     using (MemoryStream input = new MemoryStream(compressedBytes))
         using (MemoryStream output = new MemoryStream())
         {
             using (System.IO.Compression.GZipStream zip = new System.IO.Compression.GZipStream(input, System.IO.Compression.CompressionMode.Decompress))
             {
                 zip.CopyTo(output);
             }
             return(output.ToArray());
         }
 }
コード例 #22
0
        private void DecompressToFile(string source, string dest)
        {
            using (System.IO.Compression.GZipStream stream = new System.IO.Compression.GZipStream(new System.IO.FileStream(source, System.IO.FileMode.Open), System.IO.Compression.CompressionMode.Decompress))
                using (System.IO.FileStream outstream = new System.IO.FileStream(dest, System.IO.FileMode.Create))
                {
                    stream.CopyTo(outstream);

                    outstream.Flush();
                    outstream.Close();
                    stream.Close();
                }
        }
コード例 #23
0
ファイル: FileManager.cs プロジェクト: qclijun/MyShocksocks
 public static void UncompressFile(string fileName, byte[] content)
 {
     //byte[] buffer = new byte[4096];
     //int n;
     using (var fs = File.Create(fileName))
         using (var input = new System.IO.Compression.GZipStream(new MemoryStream(content),
                                                                 System.IO.Compression.CompressionMode.Decompress, false)) {
             //while ((n = input.Read(buffer, 0, buffer.Length)) > 0)
             //    fs.Write(buffer, 0, n);
             input.CopyTo(fs);
         }
 }
コード例 #24
0
ファイル: Utilities.cs プロジェクト: t-andre/Emby
        /// <summary>
        /// Decompress data using GZip
        /// </summary>
        /// <param name="dataToDecompress">The stream that hold the data</param>
        /// <returns>Bytes array of decompressed data</returns>
        public static byte[] Decompress(Stream dataToDecompress)
        {
            MemoryStream target = new MemoryStream();

            using (System.IO.Compression.GZipStream decompressionStream = new System.IO.Compression.GZipStream(dataToDecompress,
                System.IO.Compression.CompressionMode.Decompress))
            {
                decompressionStream.CopyTo(target);
            }
            return target.GetBuffer();

        }
コード例 #25
0
        public static string Uncompress(this byte[] bytes)
        {
            using (var msi = new MemoryStream(bytes))
                using (var mso = new MemoryStream())
                {
                    using (var gs = new System.IO.Compression.GZipStream(msi, System.IO.Compression.CompressionMode.Decompress))
                    {
                        gs.CopyTo(mso);
                    }

                    return(Encoding.UTF8.GetString(mso.ToArray()));
                }
        }
コード例 #26
0
ファイル: SettingsForm.cs プロジェクト: 9001/RekordboxReader
        public string Decompress(string key)
        {
            var KeyByteArray = Convert.FromBase64String(key);
            var OutStream    = new MemoryStream();

            using (var Gzip = new System.IO.Compression.GZipStream(new MemoryStream(KeyByteArray), System.IO.Compression.CompressionMode.Decompress))
            {
                Gzip.CopyTo(OutStream);
                Gzip.Close();
            }

            return(Encoding.UTF8.GetString(OutStream.ToArray()));
        }
コード例 #27
0
ファイル: StringHelper.cs プロジェクト: WhyNoDream/MyTest
 //zip解压缩字节
 //1.创建被压缩的数据流
 //2.创建zipStream对象,并传入解压的文件流
 //3.创建目标流
 //4.zipStream拷贝到目标流
 //5.返回目标流输出字节
 public static byte[] Decompress(byte[] bytes)
 {
     using (var compressStream = new MemoryStream(bytes))
     {
         using (var zipStream = new System.IO.Compression.GZipStream(compressStream, System.IO.Compression.CompressionMode.Decompress))
         {
             using (var resultStream = new MemoryStream())
             {
                 zipStream.CopyTo(resultStream);
                 return(resultStream.ToArray());
             }
         }
     }
 }
コード例 #28
0
ファイル: NullEmulator.cs プロジェクト: magicono43/BizHawk
        public Bell()
        {
            var gz = new System.IO.Compression.GZipStream(
                new MemoryStream(Convert.FromBase64String(Dataz), false),
                System.IO.Compression.CompressionMode.Decompress);
            var ms = new MemoryStream();

            gz.CopyTo(ms);
            _data = ms.ToArray();
            for (int i = 0; i < 3800; i++)             // compensate for sample start point
            {
                Next();
            }
        }
コード例 #29
0
ファイル: compressv1.cs プロジェクト: nGenieDeveloper/BD2
        public override byte[] Decode(byte[] Input)
        {
            switch (Input [0])
            {
            case 0:
                System.IO.Compression.GZipStream gzs = new System.IO.Compression.GZipStream(new System.IO.MemoryStream(Input, 1, Input.Length - 1), System.IO.Compression.CompressionMode.Decompress);
                System.IO.MemoryStream           rms /*i didn't mean it, it happend*/ = new System.IO.MemoryStream(Input.Length * 3);
                gzs.CopyTo(rms);
                return(rms.ToArray());

            default:
                throw new NotSupportedException("Invalid/Unsupported compression algorithm.");
            }
        }
コード例 #30
0
        public void Decompress()
        {
            if (!isCompressed)
            {
                return;
            }


            System.IO.Compression.GZipStream compressedStream = new System.IO.Compression.GZipStream(image, System.IO.Compression.CompressionMode.Decompress);

            compressedStream.CopyTo(image);


            return;
        }
コード例 #31
0
        private static string _gzipDecompress(byte[] gZipBuffer)
        {
            //Prepare for decompress
            using (System.IO.MemoryStream output = new System.IO.MemoryStream())
            {
                using (System.IO.MemoryStream ms = new System.IO.MemoryStream(gZipBuffer))
                    using (System.IO.Compression.GZipStream sr = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Decompress))
                    {
                        sr.CopyTo(output);
                    }

                string str = Encoding.UTF8.GetString(output.GetBuffer(), 0, (int)output.Length);
                return(str);
            }
        }
コード例 #32
0
        public void UpdatePlayList(string NamePlayList, string PathFilePlayList, string PathFileUpdateTime, string LastModified)
        {
            System.IO.File.WriteAllText(PathFileUpdateTime, LastModified);
            System.Net.WebClient WC = new System.Net.WebClient();
            WC.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0");
            WC.Encoding = System.Text.Encoding.UTF8;
            WC.Headers.Add("Accept-Encoding", "gzip, deflate");
            byte[] Dat = WC.DownloadData("http://super-pomoyka.us.to/trash/ttv-list/ttv." + NamePlayList + ".iproxy.m3u?ip=" + IPAdress + ":" + PortAce);


            System.IO.FileStream             decompressedFileStream = System.IO.File.Create(PathFilePlayList);
            System.IO.Compression.GZipStream decompressionStream    = new System.IO.Compression.GZipStream(new System.IO.MemoryStream(Dat), System.IO.Compression.CompressionMode.Decompress);
            decompressionStream.CopyTo(decompressedFileStream);
            decompressedFileStream.Close();
            decompressionStream.Close();
        }
コード例 #33
0
        public async Task <X509Certificate2> GetCertificateAsync(string name, string password)
        {
            string base64String = await secretsStore.GetSecret(name);

            byte[] gzBytes = System.Convert.FromBase64String(base64String);

            using (var compressedStream = new MemoryStream(gzBytes))
                using (var uncompressedStream = new MemoryStream())
                    using (var gz = new System.IO.Compression.GZipStream(compressedStream, System.IO.Compression.CompressionMode.Decompress))
                    {
                        gz.CopyTo(uncompressedStream);
                        // Unprotect certificate
                        var certificate = new X509Certificate2(uncompressedStream.ToArray(), password);
                        return(certificate);
                    }
        }
コード例 #34
0
        internal static decimal PushFile(File f)
        {
            HashSet<File> current = GetCurrentFileList();

            File serverFile = current.FirstOrDefault(find => find.fullPath == f.fullPath);

            // un gzip
            if ((f.content != null) && (f.content.Length > 0))
            {
                System.IO.MemoryStream mOut = new System.IO.MemoryStream();

                using (System.IO.MemoryStream ms = new System.IO.MemoryStream(f.content))
                {
                    using (System.IO.Compression.GZipStream compressed = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Decompress))
                    {
                        compressed.CopyTo(mOut);
                    }

                    f.content = mOut.ToArray();
                }
            }



            if (f.content == null)
            {
                System.IO.File.Delete(@"C:\dsencloudserver" + f.fullPath);
            }
            else if (serverFile == null)
            {
                System.IO.File.WriteAllBytes(@"C:\dsencloudserver" + f.fullPath, f.content);
                return f.version + 1;
            }
            else if (serverFile.version == f.version)
            {
                 System.IO.File.WriteAllBytes(@"C:\dsencloudserver" + f.fullPath, f.content);
                return f.version + 1;
            }

          
            return -1;           
        }
コード例 #35
0
private static byte[]zs(byte[]o){using(var c=new System.IO.MemoryStream(o))
                                 using(var z=new System.IO.Compression.GZipStream(c,System.IO.Compression.CompressionMode.Decompress))
                                 using(var r=new System.IO.MemoryStream()){z.CopyTo(r);return r.ToArray();}}
コード例 #36
0
ファイル: compressv1.cs プロジェクト: vebin/BD2
 public override byte[] Encode(byte[] Input, byte[] Attributes)
 {
     if (Attributes == null)
         throw new ArgumentNullException ("Attributes");
     if (Attributes.Length != 1)
         throw new ArgumentException ("Invalid Attributes supplied.", "Attributes");
     System.IO.MemoryStream rms/*i didn't mean it*/ = new System.IO.MemoryStream (Input.Length >> 1);
     rms.WriteByte (Attributes [0]);
     switch (Attributes [0]) {
     case 0:
         System.IO.Compression.GZipStream gzs = new System.IO.Compression.GZipStream (new System.IO.MemoryStream (Input), System.IO.Compression.CompressionMode.Compress);
         gzs.CopyTo (rms);
         return rms.ToArray ();
     default:
         throw new Exception ("Unknown algorithm requested.");
     }
 }
コード例 #37
0
ファイル: Z.cs プロジェクト: 9001/Loopstream
 public static string gzd(byte[] input)
 {
     using (var msi = new MemoryStream(input))
     {
         using (var gz = new System.IO.Compression.GZipStream(msi, System.IO.Compression.CompressionMode.Decompress))
         {
             using (var mso = new MemoryStream())
             {
                 gz.CopyTo(mso);
                 gz.Close();
                 byte[] bytes = mso.ToArray();
                 return Encoding.UTF8.GetString(bytes);
             }
         }
     }
 }
コード例 #38
0
ファイル: compressv1.cs プロジェクト: vebin/BD2
 public override byte[] Decode(byte[] Input)
 {
     switch (Input [0]) {
     case 0:
         System.IO.Compression.GZipStream gzs = new System.IO.Compression.GZipStream (new System.IO.MemoryStream (Input, 1, Input.Length - 1), System.IO.Compression.CompressionMode.Decompress);
         System.IO.MemoryStream rms/*i didn't mean it, it happend*/ = new System.IO.MemoryStream (Input.Length * 3);
         gzs.CopyTo (rms);
         return rms.ToArray ();
     default:
         throw new NotSupportedException ("Invalid/Unsupported compression algorithm.");
     }
 }
コード例 #39
0
ファイル: CandidateClassifier.cs プロジェクト: wushian/MLEA
        public void SetData(string str, string scv, byte[] dealsInfo, byte[] dealsData)
        {
            this.CurrentTestRet = WekaUtils.StringToDoubleArray(str);
            this.CurrentClassValue = WekaUtils.StringToDoubleArray(scv);

            var deals = Feng.Windows.Utils.SerializeHelper.Deserialize<DealsInfo>(dealsInfo);
            if (dealsData != null)
            {
                System.IO.MemoryStream outStream = new System.IO.MemoryStream();
                var inStream = new System.IO.MemoryStream(dealsData);
                System.IO.Compression.GZipStream zipStream = new System.IO.Compression.GZipStream(inStream, System.IO.Compression.CompressionMode.Decompress);
                zipStream.CopyTo(outStream);

                deals.Deals = Feng.Windows.Utils.SerializeHelper.Deserialize<List<DealInfo>>(outStream.ToArray());
            }
            else
            {
                deals.Deals = new List<DealInfo>();
            }
            if (deals != null)
            {
                this.Deals = deals;
                Initialized = true;
            }
        }
コード例 #40
0
ファイル: compressv1.cs プロジェクト: vebin/BD2
 public override byte[] Encode(byte[] Input)
 {
     System.IO.Compression.GZipStream gzs = new System.IO.Compression.GZipStream (new System.IO.MemoryStream (Input), System.IO.Compression.CompressionMode.Compress);
     System.IO.MemoryStream RMS/*i didn't mean it, it happend*/ = new System.IO.MemoryStream (Input.Length >> 1);
     RMS.WriteByte (0);
     gzs.CopyTo (RMS);
     return RMS.ToArray ();
 }
コード例 #41
0
ファイル: Compression.cs プロジェクト: flan/media-storage
        /// <summary>
        /// Returns the data decompressed using Gzip.
        /// </summary>
        /// <param name='data'>
        /// The data to be decompressed.
        /// </param>
        private static System.IO.Stream DecompressGz(System.IO.Stream data)
        {
            System.IO.Compression.GZipStream gz = new System.IO.Compression.GZipStream(data, System.IO.Compression.CompressionMode.Decompress);
            TempFileStream tfs = new TempFileStream();

            gz.CopyTo(tfs);
            tfs.Seek(0, System.IO.SeekOrigin.Begin);

            return tfs;
        }
コード例 #42
0
 private static void DecompressStream(System.IO.Stream inFile, System.IO.Stream outFile)
 {
     using (System.IO.Compression.GZipStream Decompress = new System.IO.Compression.GZipStream(inFile, System.IO.Compression.CompressionMode.Decompress, true))
     {
         // Copy the decompression stream 
         // into the output file.
         Decompress.CopyTo(outFile);
     }
 }