COMMON: Clean up archive path handling, add getFileName and getPathInArchive to ArchiveMember #5108
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.
Reworked this to hopefully minimize regression risk. This partially refactors archive path handling to better handle full paths and alternate path separators.
The main thing motivating this is a few things:
Archive::listMatchingMembers
callsgetName
to determine the path to match, which acts as ifgetName
returns a full path, except it may not. In particular,FSNode
archive members always return only the file name.I mainly want these to make a VFS for mTropolis to make dealing with installers easier (basically, the VFS would be an archive containing hardlinks to other archives - in order do to that though, it needs to be possible to scan an archive subpath).
The previous version of this tried just making
getName
always return only the filename, but that would require checking a LOT of engines for regressions which I think makes this too big of a project. Instead, this addsgetFileName
andgetPathInArchive
and deprecatesgetName
. This is absolutely NOT guaranteed to work correctly with all existing cases (some engines may be returning full paths fromgetFileName
, if they actually support them), but it will provide a smoother path to making this work in a sensible way.This also changes GenericArchiveMember to accept a path instead of a string. This should transparently support existing cases since
getName
will return the path converted using the same path separator, except for StuffIt (see below).This also changes
FSDirectory
to returnFSDirectoryFile
as the archive member type. The reason for this is so that when callinggetMember
with a subpath of a directory, it will return aFSDirectoryFile
for whichgetPathInArchive
returns the relative path from the directory thatgetMember
was called on instead of the parent of the file, keeping the principle that passinggetPathInArchive
back togetMember
should always return the same thing.The only case this will cause a change in behavior is directly constructing a path using an incompatible separator, which is currently only possible for StuffIt and VISE archives since they are the only ones that use alternate path separators, and the StuffIt loader flattens the directory tree by default.
However, this should improve support for MacOS filenames with slashes in them, since
StuffItArchive::getMember
will no longer interpret the slash as a separator.