Ejemplo n.º 1
0
        static int Main(string[] args)
        {
            Options options = new Options();

            for (int i = 0; i < args.Length - 1;)
            {
                if (args[i] == "-c")
                {
                    options.SourceFolderPath = args[i + 1];
                    i += 2;
                }
                else if (args[i] == "-o")
                {
                    options.DestPath = args[i + 1];
                    i += 2;
                }
                else if (args[i] == "-a")
                {
                    options.Update = true;
                    i++;
                }
                else
                {
                    Console.WriteLine("Unrecognised argument: \"{0}\"", args[i]);
                }
            }

            if (options.SourceFolderPath == null || options.DestPath == null)
            {
                Console.WriteLine("Usage: PakBuilder.exe -c SourceFolderPath -o DestPath [-a]");
                Console.WriteLine("\tThe -a flag signifies adding to an existing destination file.");
                Console.WriteLine("\tIf a source is already present in the destination it will be");
                Console.WriteLine("\toverwritten *without warning*.");
                return(1);
            }

            Dictionary <string, UInt32> crcs = CrcFileNamesInDirectory(options.SourceFolderPath);

            using (var pf = PakFile.Open(options.DestPath))
            {
                // TODO
            }

            return(0);
        }
Ejemplo n.º 2
0
        public static PakFile Open(string PakName)
        {
            PakFile result  = new PakFile(PakName);
            UInt32  lastKey = Crc32.Compute(Encoding.ASCII.GetBytes(".last"));

            // Intentionally not using "using" so the file stream won't be disposed
            var br = new BinaryReader(result._FileStream);

            PakEntry entry;

            do
            {
                entry = PakEntry.Deserialize(br);
                result.Entries.Add(entry.FullNameCrc, entry);
            }while (entry.ExtensionCrc != lastKey);

            return(result);
        }