diff --git a/DiscUtils b/DiscUtils index 24d7ddc..a99992e 160000 --- a/DiscUtils +++ b/DiscUtils @@ -1 +1 @@ -Subproject commit 24d7ddc2588837ac441260d75897ff88ba7348b8 +Subproject commit a99992e5f4c062acc0dc011fb81eef489950e896 diff --git a/IRDKit/IRDKit.csproj b/IRDKit/IRDKit.csproj index 254f456..a11a292 100644 --- a/IRDKit/IRDKit.csproj +++ b/IRDKit/IRDKit.csproj @@ -3,14 +3,13 @@ Exe - true - irdkit - ./nupkg + irdkit + irdkit net6.0;net7.0;net8.0 win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64 latest true - 0.3.3 + 0.4.0 Deterous diff --git a/IRDKit/README.md b/IRDKit/README.md index dbdbf52..d20b73b 100644 --- a/IRDKit/README.md +++ b/IRDKit/README.md @@ -1,9 +1,41 @@ -## How to use IRDKit +# How to use IRDKit -IRDKit is a tool that allows direct use of LibIRD functionality from the command line interface. The basic usage is: -``` -irdkit create game.iso -irdkit info game.ird -irdkit diff game1.ird game2.ird -``` -For detailed usage, run `irdkit help` \ No newline at end of file +IRDKit is a tool that allows direct use of LibIRD functionality from the command line interface. +For full help instructions, run `irdkit help` + +## Creating ISOs + +For all options, run `irdkit help create` + +To create an IRD from an ISO, run `irdkit create game.iso` +Multiple ISOs can be processed at once with `irdkit create game1.iso game2.iso` +Or a whole directory of ISOs can be processed with `irdkit create ./ISO`, or recursively with `irdkit create -r ./ISO` + +The IRD will be created in the same folder as the ISO, with the same filename. +A different IRD path and/or filename can be defined with `-o` or `--output=` + +### Key +By default, IRDs will be created by pulling keys from redump.org +A key can be manually provided with `-k` or `--key=` +A key file can be provided with `-f game.key` or `--key-file=` +A key from GetKey log file can be used with `-l game.getkey.log` or `--getkey-log=` + +### PIC +By default, a PIC will be generated assuming a default layerbreak +A layerbreak value can be provided with `-b` or `--layerbreak=` +A PIC from a GetKey log file can be used with `-l game.getkey.log` or `--getkey-log=` + +## Printing info + +For all options, run `irdkit help info` + +To print info about an ISO or IRD file, run `irdkit info game.iso` or `irdkit info game.ird` +The info can be printed to a file, e.g. `-o out.txt` or `--output=` +The info can be formatted as a JSON with `-j` or `--json` + +## Comparing IRDs + +For all options, run `irdkit help diff` + +To compare two IRDs, run `irdkit diff game1.ird game2.ird` +The comparison can be printed to a file, e.g. `-o out.txt` or `--output=` diff --git a/LibIRD/IRD.cs b/LibIRD/IRD.cs index 6e5b3aa..4b8efa7 100644 --- a/LibIRD/IRD.cs +++ b/LibIRD/IRD.cs @@ -405,7 +405,6 @@ namespace LibIRD private protected static byte[] GenerateD1(byte[] key) { // Validate key - ArgumentNullException.ThrowIfNull(key, nameof(key)); if (key.Length != 16) throw new ArgumentException("Disc Key must be a byte array of length 16", nameof(key)); @@ -439,7 +438,6 @@ namespace LibIRD private protected static byte[] GenerateDiscKey(byte[] d1) { // Validate key - ArgumentNullException.ThrowIfNull(d1, nameof(d1)); if (d1.Length != 16) throw new ArgumentException("Disc Key must be a byte array of length 16", nameof(d1)); @@ -473,7 +471,6 @@ namespace LibIRD private protected static byte[] GenerateD2(byte[] d2) { // Validate id - ArgumentNullException.ThrowIfNull(d2, nameof(d2)); if (d2.Length != 16) throw new ArgumentException("Disc ID must be a byte array of length 16", nameof(d2)); // Setup AES encryption @@ -506,7 +503,6 @@ namespace LibIRD private protected static byte[] GenerateDiscID(byte[] d2) { // Validate id - ArgumentNullException.ThrowIfNull(d2 , nameof(d2)); if (d2.Length != 16) throw new ArgumentException("Disc ID must be a byte array of length 16", nameof(d2)); @@ -540,7 +536,6 @@ namespace LibIRD private protected void ParseGetKeyLog(string getKeyLog) { // Validate .getkey.log file path - ArgumentNullException.ThrowIfNull(getKeyLog, nameof(getKeyLog)); if (!File.Exists(getKeyLog)) throw new FileNotFoundException(nameof(getKeyLog)); @@ -793,7 +788,11 @@ namespace LibIRD // Begin a GZip stream to write header to using MemoryStream headerStream = new(); +#if NET6_0_OR_GREATER using (GZipStream gzs = new(headerStream, CompressionLevel.SmallestSize)) +#else + using (GZipStream gzs = new(headerStream, CompressionLevel.Optimal)) +#endif { // Start reading data from the beginning of the ISO file fs.Seek(0, SeekOrigin.Begin); @@ -821,7 +820,11 @@ namespace LibIRD { // Begin a GZip stream to write footer to using MemoryStream footerStream = new(); +#if NET6_0_OR_GREATER using (GZipStream gzs = new(footerStream, CompressionLevel.SmallestSize)) +#else + using (GZipStream gzs = new(footerStream, CompressionLevel.Optimal)) +#endif { // Start reading data from after last file (PS3UPDAT.PUP) fs.Seek(UpdateEnd, SeekOrigin.Begin); @@ -1061,7 +1064,7 @@ namespace LibIRD CountFiles(dirInfo); } - #endregion +#endregion #region IRD File @@ -1176,7 +1179,11 @@ namespace LibIRD // Create the IRD file stream using FileStream fs = new(irdPath, FileMode.Create, FileAccess.Write); // Create a GZipped IRD file stream +#if NET6_0_OR_GREATER using GZipStream gzStream = new(fs, CompressionLevel.SmallestSize); +#else + using GZipStream gzStream = new(fs, CompressionLevel.Optimal); +#endif // Write entire gzipped IRD stream to file stream.Position = 0; stream.CopyTo(gzStream); diff --git a/LibIRD/LibIRD.csproj b/LibIRD/LibIRD.csproj index 37430ff..f690d96 100644 --- a/LibIRD/LibIRD.csproj +++ b/LibIRD/LibIRD.csproj @@ -2,11 +2,12 @@ - net6.0;net7.0;net8.0 + net6.0;net7.0;net8.0 win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64 latest true - 0.3.3 + 0.4.0 + ../nupkg Deterous diff --git a/LibIRD/PS3_DiscSFB.cs b/LibIRD/PS3_DiscSFB.cs index c3e059f..03e3ea0 100644 --- a/LibIRD/PS3_DiscSFB.cs +++ b/LibIRD/PS3_DiscSFB.cs @@ -33,12 +33,8 @@ namespace LibIRD /// Constructor using a PARAM.SFO file path /// /// Full file path to the PS3_DISC.SFB file - /// public PS3_DiscSFB(string sfbPath) { - // Validate file path - ArgumentNullException.ThrowIfNull(sfbPath, nameof(sfbPath)); - // Read file as a stream, and parse file using FileStream fs = new(sfbPath, FileMode.Open, FileAccess.Read); Parse(fs); diff --git a/publish-irdkit.ps1 b/publish-irdkit.ps1 new file mode 100644 index 0000000..cd63146 --- /dev/null +++ b/publish-irdkit.ps1 @@ -0,0 +1,15 @@ +dotnet publish -c Release -f net8.0 -r win-x86 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj +dotnet publish -c Release -f net8.0 -r win-x64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj +dotnet publish -c Release -f net8.0 -r win-arm64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj +dotnet publish -c Release -f net8.0 -r linux-x64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj +dotnet publish -c Release -f net8.0 -r linux-arm64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj +dotnet publish -c Release -f net8.0 -r osx-x64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj +dotnet publish -c Release -f net8.0 -r osx-arm64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj + +Compress-Archive -Path "./IRDKit/bin/Release/net8.0/win-x86/publish/irdkit.exe" -Destination "./irdkit-win-x86.zip" -CompressionLevel "Optimal" +Compress-Archive -Path "./IRDKit/bin/Release/net8.0/win-x64/publish/irdkit.exe" -Destination "./irdkit-win-x64.zip" -CompressionLevel "Optimal" +Compress-Archive -Path "./IRDKit/bin/Release/net8.0/win-arm64/publish/irdkit.exe" -Destination "./irdkit-win-arm64.zip" -CompressionLevel "Optimal" +Compress-Archive -Path "./IRDKit/bin/Release/net8.0/linux-x64/publish/irdkit" -Destination "./irdkit-linux-x64.zip" -CompressionLevel "Optimal" +Compress-Archive -Path "./IRDKit/bin/Release/net8.0/linux-arm64/publish/irdkit" -Destination "./irdkit-linux-arm64.zip" -CompressionLevel "Optimal" +Compress-Archive -Path "./IRDKit/bin/Release/net8.0/osx-x64/publish/irdkit" -Destination "./irdkit-osx-x64.zip" -CompressionLevel "Optimal" +Compress-Archive -Path "./IRDKit/bin/Release/net8.0/osx-arm64/publish/irdkit" -Destination "./irdkit-osx-arm64.zip" -CompressionLevel "Optimal" \ No newline at end of file