protected int OnExecute(CommandLineApplication app) { var outputDir = OutputDir ?? Path.Combine(Path.GetDirectoryName(InputIso), "extract"); using var stream = File.OpenRead(InputIso); var firstBlock = IsoUtility.GetFileOffset(stream, "SYSTEM.CNF;1"); if (firstBlock == -1) { throw new IOException("The file specified seems to not be a valid PlayStation 2 ISO."); } var kingdomIdxBlock = IsoUtility.GetFileOffset(stream, "KINGDOM.IDX;1"); if (kingdomIdxBlock == -1) { throw new IOException("The file specified seems to not be a Kingdom Hearts 1 ISO"); } var idx = Idx1.Read(stream.SetPosition(kingdomIdxBlock * IsoBlockAlign)); var img = new Img1(stream, idx, firstBlock); ExtractIdx(img, outputDir, DoNotExtractAgain); return(0); }
protected int OnExecute(CommandLineApplication app) { using var stream = File.OpenRead(InputIso); var firstBlock = IsoUtility.GetFileOffset(stream, "SYSTEM.CNF;1"); if (firstBlock == -1) { throw new IOException("The file specified seems to not be a valid PlayStation 2 ISO."); } var kingdomIdxBlock = IsoUtility.GetFileOffset(stream, "KINGDOM.IDX;1"); if (kingdomIdxBlock == -1) { throw new IOException("The file specified seems to not be a Kingdom Hearts 1 ISO"); } var idx = Idx1.Read(stream.SetPosition(kingdomIdxBlock * IsoBlockAlign)); foreach (var entry in idx.OrderBy(x => x.IsoBlock)) { Console.WriteLine(Idx1Name.Lookup(entry) ?? $"@{entry.Hash:X08}"); } return(0); }
public Stream FileOpen(Idx1 entry) { if (entry.CompressionFlag != 0) { var fileStream = new SubStream(_stream, (_firstBlock + entry.IsoBlock) * IsoBlockAlign, entry.Length); return(new MemoryStream(Decompress(fileStream))); } return(new SubStream(_stream, (_firstBlock + entry.IsoBlock) * IsoBlockAlign, entry.Length)); }
public void CalculateHash(string text, uint hash) { Assert.Equal(hash, Idx1.GetHash(text)); }