Ejemplo n.º 1
0
 public static void WriteToBinary(LbaFile lba, string path)
 {
     using (BinaryWriter writer = new BinaryWriter(new FileStream(path, FileMode.Create)))
     {
         lba.Write(writer);
     }
 }
Ejemplo n.º 2
0
        public static LbaFile ReadFromBinary(string path, HashManager hashManager)
        {
            LbaFile lba = new LbaFile();

            using (BinaryReader reader = new BinaryReader(new FileStream(path, FileMode.Open)))
            {
                lba.Read(reader, hashManager);
            }
            return(lba);
        }
Ejemplo n.º 3
0
        public static void WriteToXml(LbaFile lba, string path)
        {
            XmlWriterSettings xmlWriterSettings = new XmlWriterSettings()
            {
                Encoding = Encoding.UTF8,
                Indent   = true
            };

            using (var writer = XmlWriter.Create(path, xmlWriterSettings))
            {
                lba.WriteXml(writer);
            }
        }
Ejemplo n.º 4
0
        public static LbaFile ReadFromXml(string path)
        {
            XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
            {
                IgnoreWhitespace = true
            };

            LbaFile lba = new LbaFile();

            using (var reader = XmlReader.Create(path, xmlReaderSettings))
            {
                lba.ReadXml(reader);
            }
            return(lba);
        }
Ejemplo n.º 5
0
        private static void Main(string[] args)
        {
            var hashManager = new HashManager();

            // Read hash dictionaries
            if (File.Exists(DefaultNameDictionaryFileName))
            {
                hashManager.StrCode32LookupTable  = MakeHashLookupTableFromFile(DefaultNameDictionaryFileName, FoxHash.Type.StrCode32);
                hashManager.PathCode32LookupTable = MakeHashLookupTableFromFile(DefaultDataSetDictionaryFileName, FoxHash.Type.PathCode32);
            }

            foreach (var lbaPath in args)
            {
                if (File.Exists(lbaPath))
                {
                    // Read input file
                    string fileExtension = Path.GetExtension(lbaPath);
                    if (fileExtension.Equals(".xml", StringComparison.OrdinalIgnoreCase))
                    {
                        LbaFile lba = ReadFromXml(lbaPath);
                        WriteToBinary(lba, Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(lbaPath)) + ".lba");
                    }
                    else if (fileExtension.Equals(".lba", StringComparison.OrdinalIgnoreCase))
                    {
                        LbaFile lba = ReadFromBinary(lbaPath, hashManager);
                        WriteToXml(lba, Path.GetFileNameWithoutExtension(lbaPath) + ".lba.xml");
                    }
                    else
                    {
                        throw new IOException("Unrecognized input type.");
                    }
                }
            }

            // Write hash matches output
            WriteHashMatchesToFile(DefaultHashMatchOutputFileName, hashManager);
        }