public static ROMInfo getROMInfo(Handler handler, ROMFile rom, DatfileCollection datfiles) { ROMInfo info = new ROMInfo(); try { info.addInfo("Filename", rom.path.Name); info.addInfo("Folder", rom.path.DirectoryName); info.addInfo("Size", rom.length, FormatMode.SIZE); bool shouldSkipHeader = handler.shouldSkipHeader(rom); info.addInfo("Has extra header", shouldSkipHeader); if (rom.compressed) { info.addInfo("Uncompressed filename", rom.name); info.addInfo("Compressed size", rom.compressedLength, FormatMode.SIZE); info.addInfo("Compression ratio", 1 - ((double)rom.compressedLength / rom.length), FormatMode.PERCENT); } string extension = rom.extension; string fileType = handler.getFiletypeName(extension); info.addInfo("File type", fileType ?? "Unknown"); if (handler.shouldCalculateHash) { var hashes = DatfileCollection.hash(rom.stream, 0); info.addInfo("CRC32", hashes.Item1, FormatMode.HEX_WITHOUT_0X); info.addInfo("MD5", hashes.Item2, FormatMode.BYTEARRAY_WITHOUT_DASHES); info.addInfo("SHA-1", hashes.Item3, FormatMode.BYTEARRAY_WITHOUT_DASHES); Tuple <int, byte[], byte[]> hashesWithoutHeader = null; if (shouldSkipHeader) { hashesWithoutHeader = DatfileCollection.hash(rom.stream, handler.skipHeaderBytes()); info.addInfo("CRC32 without header", hashesWithoutHeader.Item1, FormatMode.HEX_WITHOUT_0X); info.addInfo("MD5 without header", hashesWithoutHeader.Item2, FormatMode.BYTEARRAY_WITHOUT_DASHES); info.addInfo("SHA-1 without header", hashesWithoutHeader.Item3, FormatMode.BYTEARRAY_WITHOUT_DASHES); } if (datfiles != null) { var results = datfiles.identify(hashes.Item1, hashes.Item2, hashes.Item3); if (hashesWithoutHeader != null) { var resultsWithoutHeader = datfiles.identify(hashesWithoutHeader.Item1, hashesWithoutHeader.Item2, hashesWithoutHeader.Item3); foreach (var resultWithoutHeader in resultsWithoutHeader) { results.Add(resultWithoutHeader); } } addDatfileResults(results, info); } } handler.addROMInfo(info, rom); } catch (Exception e) { info.addInfo("Exception", e); } return(info); }
public static ROMInfo getROMInfo(Handler handler, ROMFile rom) { return(getROMInfo(handler, rom, null)); }