예제 #1
0
        public void normalizeModFile(string pathToZip, string expectedDirectoryName)
        {
            string foundRootDirectory;

            if (!shouldZipBeNormalized(pathToZip, expectedDirectoryName, out foundRootDirectory))
            {
                return;
            }
            // prepare
            string extractZipDir = getTemporaryDirectory();
            string createZipDir  = getTemporaryDirectory();

            // extract zip, delete zip, move root, create new zip with fixed root
            SimpleZip.ExtractZip(pathToZip, extractZipDir);
            Directory.Move(Path.Combine(extractZipDir, foundRootDirectory), Path.Combine(createZipDir, expectedDirectoryName));
            File.Delete(pathToZip);
            SimpleZip.CreateZip(pathToZip, createZipDir);

            // cleanup - if found root directory was empty, we moved the entire directory and there's nothing to delete
            if (foundRootDirectory != "")
            {
                Directory.Delete(extractZipDir, true);
            }
            Directory.Delete(createZipDir, true);
        }
예제 #2
0
 public static void ExtractPackageFile(string packagePath, string relativeFilePath, Stream outputStream)
 {
     using (FileStream packageStream = File.OpenRead(packagePath))
     {
         SimpleZip.UnzipFile(packageStream, outputStream, relativeFilePath, null);
     }
 }
예제 #3
0
 // Token: 0x060002C4 RID: 708 RVA: 0x00027F28 File Offset: 0x00026128
 static Strings()
 {
     if (Strings.MustUseCache == "1")
     {
         Strings.cacheStrings = true;
         Strings.hashtable    = new Dictionary <int, string>();
     }
     Strings.offset = Convert.ToInt32(Strings.OffsetValue);
     using (Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("{e4775d96-dfa1-43fa-97d8-8f29405b74d4}"))
     {
         int    num   = Convert.ToInt32(manifestResourceStream.Length);
         byte[] array = new byte[num];
         manifestResourceStream.Read(array, 0, num);
         Strings.bytes = SimpleZip.Unzip(array);
     }
 }
예제 #4
0
        public static void Apply(PackageContext packageContext, ManifestItem manifestItem, string destinationPath, bool overwrite)
        {
            if (manifestItem == null)
            {
                throw new ArgumentNullException("manifestItem");
            }

            if (!File.Exists(destinationPath) || overwrite)
            {
                using (Stream inputStream = File.OpenRead(packageContext.Package.Path))
                {
                    using (Stream outputStream = File.OpenWrite(destinationPath))
                    {
                        SimpleZip.UnzipFile(inputStream, outputStream, manifestItem.RelativePath, null);
                    }
                }
            }
        }
예제 #5
0
        public override void Apply(PackageContext packageContext)
        {
            List <PackageContext> packageContexts = new List <PackageContext>();

            //Need to look at all packages that are referenced and copy files from them in order.
            packageContexts.AddRange(packageContext.Package.PackageReferences.Select(o => new PackageContext(o.Package, packageContext.OutputPath, packageContext.InputResults)));
            packageContexts.Add(packageContext);

            foreach (PackageContext currentPackageContext in packageContexts)
            {
                if (currentPackageContext.Package.Manifest.Automatic)
                {
                    string[] filesToDelete =
                    {
                        currentPackageContext.GetAbsoluteOutputPath(Package.PackageXmlFileName),
                        currentPackageContext.GetAbsoluteOutputPath(Package.PackageIconFileName)
                    };

                    using (Stream stream = File.OpenRead(currentPackageContext.Package.Path))
                    {
                        SimpleZip.Unzip(stream, packageContext.OutputPath + "\\", null);
                    }

                    //Delete package-related files.
                    foreach (string filePath in filesToDelete)
                    {
                        if (File.Exists(filePath))
                        {
                            File.Delete(filePath);
                        }
                    }
                }
                else
                {
                    foreach (ManifestItem item in currentPackageContext.Package.Manifest.Items.Where(i => !i.DoNotCopy))
                    {
                        CopyAction.Apply(currentPackageContext, item, currentPackageContext.GetAbsoluteOutputPath(item.RelativePath), true);
                    }
                }
            }
        }
        internal static Assembly ResolveAssembly(object sender, ResolveEventArgs e)
        {
            AssemblyInfo info             = new AssemblyInfo(e.Name);
            string       assemblyFullName = info.GetAssemblyFullName(false);
            string       str2             = Convert.ToBase64String(Encoding.UTF8.GetBytes(assemblyFullName));

            string[] strArray = "ezJiMjQwNDRmLTY0NDgtNDczMi1hMGQ4LTlhNGIzNzg0MWY0N30sIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49M2U1NjM1MDY5M2Y3MzU1ZQ==,[z]{5afba4e7-4cbd-48f4-ae87-5cb4a100aac0},ezJiMjQwNDRmLTY0NDgtNDczMi1hMGQ4LTlhNGIzNzg0MWY0N30=,[z]{5afba4e7-4cbd-48f4-ae87-5cb4a100aac0},SHRtbEFnaWxpdHlQYWNrLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWJkMzE5YjE5ZWFmM2I0M2E=,[z]{22a11d39-8946-4a47-958b-a3b1fb426f2d},SHRtbEFnaWxpdHlQYWNr,[z]{22a11d39-8946-4a47-958b-a3b1fb426f2d}".Split(new char[] { ',' });
            string   key      = string.Empty;
            bool     flag     = false;
            bool     flag2    = false;

            for (int i = 0; i < (strArray.Length - 1); i += 2)
            {
                if (strArray[i] == str2)
                {
                    key = strArray[i + 1];
                    break;
                }
            }
            if ((key.Length == 0) && (info.PublicKeyToken.Length == 0))
            {
                str2 = Convert.ToBase64String(Encoding.UTF8.GetBytes(info.Name));
                for (int j = 0; j < (strArray.Length - 1); j += 2)
                {
                    if (strArray[j] == str2)
                    {
                        key = strArray[j + 1];
                        break;
                    }
                }
            }
            if (key.Length > 0)
            {
                if (key[0] == '[')
                {
                    int    index = key.IndexOf(']');
                    string str4  = key.Substring(1, index - 1);
                    flag  = str4.IndexOf('z') >= 0;
                    flag2 = str4.IndexOf('t') >= 0;
                    key   = key.Substring(index + 1);
                }
                lock (hashtable)
                {
                    if (hashtable.ContainsKey(key))
                    {
                        return(hashtable[key]);
                    }
                    Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(key);
                    if (manifestResourceStream != null)
                    {
                        int    length = (int)manifestResourceStream.Length;
                        byte[] buffer = new byte[length];
                        manifestResourceStream.Read(buffer, 0, length);
                        if (flag)
                        {
                            buffer = SimpleZip.Unzip(buffer);
                        }
                        Assembly assembly = null;
                        if (!flag2)
                        {
                            try
                            {
                                assembly = Assembly.Load(buffer);
                            }
                            catch (FileLoadException)
                            {
                                flag2 = true;
                            }
                            catch (BadImageFormatException)
                            {
                                flag2 = true;
                            }
                        }
                        if (flag2)
                        {
                            try
                            {
                                string path = string.Format(@"{0}{1}\", Path.GetTempPath(), key);
                                Directory.CreateDirectory(path);
                                string str6 = path + info.Name + ".dll";
                                if (!File.Exists(str6))
                                {
                                    FileStream stream2 = File.OpenWrite(str6);
                                    stream2.Write(buffer, 0, buffer.Length);
                                    stream2.Close();
                                    MoveFileEx(str6, null, 4);
                                    MoveFileEx(path, null, 4);
                                }
                                assembly = Assembly.LoadFile(str6);
                            }
                            catch
                            {
                            }
                        }
                        hashtable[key] = assembly;
                        return(assembly);
                    }
                }
            }
            return(null);
        }