BUG: Read the extension from the final path component in get_ext#52
Open
hjmjohnson wants to merge 1 commit into
Open
BUG: Read the extension from the final path component in get_ext#52hjmjohnson wants to merge 1 commit into
hjmjohnson wants to merge 1 commit into
Conversation
get_ext() scanned the entire path for '.' via rfind, so a dot anywhere in a parent directory was treated as the file extension. A common trigger is a version-numbered build/output path: for ".../build-5.4/.../trx_test" (a file with no extension) get_ext returned "4/.../trx_test", which the writer rejects with "Unsupported extension". Restrict the search to the final path component (after the last '/' or '\'), then take the substring after its last '.'. A file with no dot in its name now correctly yields an empty extension. This does not change the dtype-extraction callers: array element filenames such as "positions.3.float32" and "offsets.uint64" carry the dot in the basename, so the returned dtype is unchanged. Adds TrxFileIo.get_ext_uses_final_path_component covering the dotted-parent regression, no-extension, no-separator, dtype-filename, and trailing-dot cases. Full ctest suite passes 185/185. Found via an ITK v5-vs-v6 downstream build testbed whose build path contained a dotted directory; the three ITKTractographyTRX tests that failed there pass with this fix.
Author
|
@mattcieslak Some fixes exposed while trying to build TRX with both ITKv5 and ITKv6. |
hjmjohnson
marked this pull request as ready for review
July 17, 2026 19:10
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.
get_ext()scans the entire path for., so a dot in any parent directory is mistaken for the file extension. For a version-numbered build/output path like.../build-5.4/…/trx_test(a file with no extension),get_extreturns"4/…/trx_test", which the writer rejects with "Unsupported extension". This fixes it to read the extension from the final path component only.Root cause
rfind('.')on the full path finds the dot inbuild-5.4, not in the filename:The fix restricts the search to the substring after the last
/or\, then takes the part after that component's last..No change to dtype extraction
get_extis also used to read the dtype from array element filenames (positions.3.float32,offsets.uint64). Those carry the dot in the basename, so the returned dtype is unchanged — the fix only differs when the basename has no dot but a parent directory does.Testing
Adds
TrxFileIo.get_ext_uses_final_path_component:Full
ctestsuite passes 185/185 (the dtype callers are exercised bytest_io).Found via an ITK v5-vs-v6 downstream build testbed whose build path contained a dotted directory; the three
ITKTractographyTRXtests that failed there pass with this change.