Example #1
0
        public static GZipResult Decompress(string lpSrcFolder, string lpDestFolder, string zipFileName, bool deleteTempFile, bool writeFiles, string addExtension, Hashtable htFiles, int bufferSize)
        {
            // This item is obfuscated and can not be translated.
            GZipResult result = new GZipResult();

            if (!lpSrcFolder.EndsWith(@"\"))
            {
                lpSrcFolder = lpSrcFolder + @"\";
            }
            if (!lpDestFolder.EndsWith(@"\"))
            {
                lpDestFolder = lpDestFolder + @"\";
            }
            string str  = lpSrcFolder + zipFileName + ".tmp";
            string str2 = lpSrcFolder + zipFileName;

            result.TempFile = str;
            result.ZipFile  = str2;
            string       str3   = null;
            string       str4   = null;
            string       path   = null;
            GZipFileInfo info   = null;
            FileStream   stream = null;
            ArrayList    list   = new ArrayList();
            bool         flag   = false;

            if (string.IsNullOrEmpty(addExtension))
            {
                addExtension = string.Empty;
            }
            else if (!addExtension.StartsWith("."))
            {
                addExtension = "." + addExtension;
            }
            try
            {
                stream = smethod_7(str2, str, result);
                if (stream != null)
                {
                    while (stream.Position != stream.Length)
                    {
                        str3 = null;
                        while (!string.IsNullOrEmpty(str3))
                        {
                            if (0 == 0)
                            {
                                goto Label_00EF;
                            }
                            str3 = smethod_4(stream);
                        }
                        goto Label_00C4;
Label_00EF:
                        if (!string.IsNullOrEmpty(str3))
                        {
                            info = new GZipFileInfo();
                            if (!info.ParseFileInfo(str3) || (info.Length <= 0))
                            {
                                continue;
                            }
                            list.Add(info);
                            str4           = lpDestFolder + info.RelativePath;
                            path           = smethod_6(str4);
                            info.LocalPath = str4;
                            flag           = false;
                            if ((htFiles == null) || htFiles.ContainsKey(info.RelativePath))
                            {
                                info.RestoreRequested = true;
                                flag = writeFiles;
                            }
                            if (flag)
                            {
                                if (!Directory.Exists(path))
                                {
                                    Directory.CreateDirectory(path);
                                }
                                info.Restored = smethod_5(stream, info.Length, str4 + addExtension, bufferSize);
                                continue;
                            }
                            stream.Position += info.Length;
                        }
                    }
                }
            }
            catch
            {
                result.Errors = true;
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                    stream = null;
                }
            }
            try
            {
                if (deleteTempFile)
                {
                    File.Delete(str);
                    result.TempFileDeleted = true;
                }
            }
            catch
            {
                result.Errors = true;
            }
            result.FileCount = list.Count;
            result.Files     = new GZipFileInfo[list.Count];
            list.CopyTo(result.Files);
            return(result);
        }