[#151] Add --entry to dump and serialized-file to read a SerializedFile inside an archive - #152
Merged
Merged
Conversation
…le inside an archive
SkowronskiAndrew
left a comment
Collaborator
Author
There was a problem hiding this comment.
This PR looks like it provides the desired functionality. But i have comments with suggestions to improve the implementation
| UnityArchive m_Archive; | ||
|
|
||
| // Path of the SerializedFile inside the archive, as shown by `archive list`. | ||
| public string Name { get; } |
Collaborator
Author
There was a problem hiding this comment.
Name is vague. The comment explains it but when look at the constructor its not clear what is expected.
…s from the CLI layer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #151.
An archive (AssetBundle, Player
data.unity3d, Content Directorycontent0.archive) often holds several SerializedFiles. Until nowdumpcould only write all of them to files, or use--stdoutif the archive had exactly one, andserialized-filerefused archives entirely, so reaching one SerializedFile meant runningarchive extractfirst. Scripts that wanted to avoid that cost ended up mounting archives themselves through UnityFileSystemApi.This adds
-e/--entry <name>todumpand to everyserialized-filesubcommand. UnityDataTool mounts the archive, reads the named SerializedFile in place, and unmounts it. Nothing is extracted to disk.The name is what
archive listshows. It is also theserialized_filecolumn ofobject_view, so an agent can go straight from a query result to a dump.Changes
UnityBinaryFormat/MountedSerializedFilehelper: mounts the archive and selects the SerializedFile. On failure it throwsSerializedFileSelectionException, which says what failed and lists the SerializedFiles.Program.csturns that into the--entryerror messages, so the CLI wording stays out of UnityBinaryFormat. Both commands follow the same rules:--entry: that SerializedFile is used. An unknown name or a non-SerializedFile entry (e.g..resS) is an error that lists the SerializedFiles in the archive.--entry: if the archive has exactly one SerializedFile, it is used. This was already howdump --stdoutworked, and it now applies toserialized-filetoo. If there are several, the error lists them and shows the--entrysyntax.--entryon a file that is not an archive is an error.serialized-file: reads through a Stream, either aFileStreamor a bufferedUnityFileStreamon the mounted entry, using the existing Stream overloads ofSerializedFileDetector. It no longer rejects archives.dump:--entry, or--stdouton an archive, dumps one SerializedFile.dump <archive>without either still dumps every SerializedFile to its own.txt.command-dump.md,command-serialized-file.md(the "SerializedFile vs Archive" section, which said to extract first, is replaced),agent-guide.md(the dump example now passes-e <serialized_file>, so it works for multi-file bundles),assetbundle-format.md.Testing
dotnet test: full suite green.SerializedFileCommandTestsandDumpTestscover:--entryselection, both to stdout and to a file.--entry, including a legacy bundle and a bundle without TypeTrees.--entry, an unknown entry, a non-SerializedFile entry, and--entryon a plain file.serialized-fileto refuse archives were removed. The existingdump --stdoutmulti-file test was updated for the new message.scenesandassetbundletest bundles.