-
Notifications
You must be signed in to change notification settings - Fork 4
Implement model, reader, wrapper for valve SKU sis files. #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement model, reader, wrapper for valve SKU sis files. #54
Conversation
|
PR is ready for review. Let me know if there's anything I still need to do, this should be fully complete. |
…memory (SabreTools#56) * WIP * WIP 2 * Todo: you're missing a read somehow and getting misaligned by two bytes? maybe properly implementing the buffer will magically fix it * continued blocks my behated * Pre-major-testing * Forgot to add summaries * Attempt to properly roll back. The state i wanted to roll back to wasn't in a commit before. * Figured out the issue with the rolled back commit, this has to be a while loop because of 0 byte files. Reimplemented clean code. * Comment so I don't forget why it's like this * Skip unsupported compression types before opening filestream. * Reenable non-start cab skipping * TODO so i don't forget * TODO so I don't forget * iterate on continued block correctly. * Handle incomplete extraction better * Remove TODOs to ready for PR comments * Missed one * Some minor fixes before rewriting everything * Next round of fixes. * Next set of fixes * Fix debug output
… methods (SabreTools#57) * Attempt 1 * Use private helper class * Remove comment * Add missing summaries * Don't use create pattern * Remove removed variable summary * Reduce what needs to be passed in * Further reduce what needs to be passed in * These didn't get tabbed for some reason * First round of fixes. * Second round of changes * Add a few comments.
* Re-enable extraction from stream * Remove todo pre PR * Properly support all situations, remove whitespace
…stead of living in PortableExecutable (SabreTools#59) * Figure out how to access OverlayAddress in wrapper or reader (ideally the latter) for a non-PE reader/wrapper * Code works * Remove TODOs * First round of fixes. * use constants * remove comment
I had previously been under the assumption that closing always guaranteed a flush. I don't know of any issues that were being caused, but I should push this before i forget.
mnadareski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused with the naming here. I'm seeing both SkuSis and VDF being used seemingly interchangeably. Is there a difference here in what both mean? Is one preferable over the other? Or is this a subset situation like COFF and PE?
| /// <summary> | ||
| /// A JSON Object representing the VDF structure. | ||
| /// </summary> | ||
| public JObject? VDFObject { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure this is a complicated question, but why does this have to be a JObject and not another structure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What other structures would you use? I'm open to others if you have any specific suggestions, JObject was just what I happened to find worked best out of all the various JSON-based options.
| using System; | ||
| using System.IO; | ||
| using SabreTools.IO.Extensions; | ||
| using File = SabreTools.Data.Models.VDF.File; | ||
| using static SabreTools.Data.Models.VDF.Constants; | ||
| using System.Text; | ||
| using Newtonsoft.Json.Linq; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure usings are ordered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also just for future reference- how do
using File = SabreTools.Data.Models.VDF.File;
using static SabreTools.Data.Models.VDF.Constants;
get alphabetized?
Do I
- alphabetize based on the first letter no matter what
- alphabetize based on the name of the actual package (in this case SabreTools.Data.whatever)
- put them after all the "normal" using statements
| if (skuSis == null) | ||
| return null; | ||
|
|
||
| if (skuSis.VDFObject == null) | ||
| return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If both are required, you can replace this by a if (skuSis?.VDFObject == null) check instead.
| string json = "{\n"; // Sku sis files have no surrounding curly braces, which json doesn't allow | ||
| string delimiter = "\"\t\t\""; // KVPs are always quoted, and are delimited by two tabs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two would likely benefit from being const.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json is the string that gets updated, so that one can't be const, unless you want me to copy it.
|
|
||
| string json = "{\n"; // Sku sis files have no surrounding curly braces, which json doesn't allow | ||
| string delimiter = "\"\t\t\""; // KVPs are always quoted, and are delimited by two tabs | ||
| string? line; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If line is never used outside of the loop, please instantiate it in the loop.
|
|
||
| #region SkuSis | ||
|
|
||
| // TODO: add description |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: please add description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, I thought I fixed this already, I specifically went through all my TODOs before undrafting. Not sure why this is still here.
That said, I'm also not sure why I said this? Very few of the other regions have descriptions. Do you have any idea why it's there?
| // TODO: add description | ||
| if (magic.StartsWith(Data.Models.VDF.Constants.SteamSimSidSisSignatureBytes) | ||
| || magic.StartsWith(Data.Models.VDF.Constants.SteamCsmCsdSisSignatureBytes)) | ||
| return WrapperType.SkuSis; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curly braces please
…memory (SabreTools#56) * WIP * WIP 2 * Todo: you're missing a read somehow and getting misaligned by two bytes? maybe properly implementing the buffer will magically fix it * continued blocks my behated * Pre-major-testing * Forgot to add summaries * Attempt to properly roll back. The state i wanted to roll back to wasn't in a commit before. * Figured out the issue with the rolled back commit, this has to be a while loop because of 0 byte files. Reimplemented clean code. * Comment so I don't forget why it's like this * Skip unsupported compression types before opening filestream. * Reenable non-start cab skipping * TODO so i don't forget * TODO so I don't forget * iterate on continued block correctly. * Handle incomplete extraction better * Remove TODOs to ready for PR comments * Missed one * Some minor fixes before rewriting everything * Next round of fixes. * Next set of fixes * Fix debug output
* Re-enable extraction from stream * Remove todo pre PR * Properly support all situations, remove whitespace
…stead of living in PortableExecutable (SabreTools#59) * Figure out how to access OverlayAddress in wrapper or reader (ideally the latter) for a non-PE reader/wrapper * Code works * Remove TODOs * First round of fixes. * use constants * remove comment
I had previously been under the assumption that closing always guaranteed a flush. I don't know of any issues that were being caused, but I should push this before i forget.
See the explanation at the top of the Readers file. |
|
closing and reopening because apparently i don't know how to merge |
This PR is a draft until I do another pass for proper formatting and commenting, as well as more testing, and other requirements that need to be fulfilled.