Ejemplo n.º 1
0
 public static void Save(string path, Dictionary <ulong, List <ulong> > sounds, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, Dictionary <ulong, ulong> replace = null, HashSet <ulong> done = null)
 {
     if (done == null)
     {
         done = new HashSet <ulong>();
     }
     foreach (KeyValuePair <ulong, List <ulong> > pair in sounds)
     {
         string rootOutput = $"{path}{GUID.LongKey(pair.Key):X12}{Path.DirectorySeparatorChar}";
         foreach (ulong key in pair.Value)
         {
             if (!done.Add(key))
             {
                 continue;
             }
             ulong  typ = GUID.Type(key);
             string ext = "wem";
             if (typ == 0x043)
             {
                 ext = "bnk";
             }
             if (!Directory.Exists(rootOutput))
             {
                 Directory.CreateDirectory(rootOutput);
             }
             string outputPath = $"{rootOutput}{GUID.LongKey(key):X12}.{ext}";
             using (Stream soundStream = Util.OpenFile(map[key], handler)) {
                 if (soundStream == null)
                 {
                     //Console.Out.WriteLine("Failed to dump {0}, probably missing key", ooutputPath);
                     continue;
                 }
                 using (Stream outputStream = File.Open(outputPath, FileMode.Create)) {
                     Util.CopyBytes(soundStream, outputStream, (int)soundStream.Length);
                     if (!quiet)
                     {
                         Console.Out.WriteLine("Wrote file {0}", outputPath);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        public void Save(string path, Record record, CASCHandler handler, string mode, bool quiet)
        {
            string output = Path.Combine(path, mode, $"{GUID.Type(record.record.Key):X3}", $"{GUID.LongKey(record.record.Key):X12}.{GUID.Type(record.record.Key):X3}");

            using (Stream acp = Util.OpenFile(record, handler)) {
                if (acp == null)
                {
                    return;
                }
                if (!Directory.Exists(Path.GetDirectoryName(output)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(output));
                }
                using (Stream file = File.Open(output, FileMode.Create)) {
                    Util.CopyBytes(acp, file, (int)acp.Length);
                    if (!quiet)
                    {
                        Console.Out.WriteLine("Wrote file {0}", output);
                    }
                }
            }
        }