Ejemplo n.º 1
0
        private static void createVanillaCatFromCas(string directory)
        {
            string text = directory + "cas.cat";

            if (!File.Exists(text))
            {
                MessageBox.Show("No cat file to restore found.");
                return;
            }
            using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(text, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)))
            {
                binaryWriter.Write("NyanNyanNyanNyan".ToCharArray());
                for (int i = 1; i < 50; i++)
                {
                    string path = directory + "cas_" + ((i < 10) ? ("0" + i) : i.ToString()) + ".cas";
                    try
                    {
                        using (BinaryReader binaryReader = new BinaryReader(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
                        {
                            while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
                            {
                                CasHeader casHeader = new CasHeader(binaryReader);
                                binaryWriter.Write(casHeader.sha1);
                                binaryWriter.Write((uint)binaryReader.BaseStream.Position);
                                binaryWriter.Write(casHeader.size);
                                binaryWriter.Write(i);
                                binaryReader.BaseStream.Position += (long)((ulong)casHeader.size);
                            }
                        }
                    }
                    catch
                    {
                        break;
                    }
                }
            }
            File.Copy(text, directory + "cas.cat_backup", true);
        }
Ejemplo n.º 2
0
 private static void createVanillaCatFromCas(string directory)
 {
     string text = directory + "cas.cat";
     if (!File.Exists(text))
     {
         MessageBox.Show("No cat file to restore found.");
         return;
     }
     using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(text, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)))
     {
         binaryWriter.Write("NyanNyanNyanNyan".ToCharArray());
         for (int i = 1; i < 50; i++)
         {
             string path = directory + "cas_" + ((i < 10) ? ("0" + i) : i.ToString()) + ".cas";
             try
             {
                 using (BinaryReader binaryReader = new BinaryReader(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
                 {
                     while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
                     {
                         CasHeader casHeader = new CasHeader(binaryReader);
                         binaryWriter.Write(casHeader.sha1);
                         binaryWriter.Write((uint)binaryReader.BaseStream.Position);
                         binaryWriter.Write(casHeader.size);
                         binaryWriter.Write(i);
                         binaryReader.BaseStream.Position += (long)((ulong)casHeader.size);
                     }
                 }
             }
             catch
             {
                 break;
             }
         }
     }
     File.Copy(text, directory + "cas.cat_backup", true);
 }