Skip to content

Uses decoded URI directly for filename extraction#521

Open
mklefrancois wants to merge 8 commits intosyoyo:releasefrom
mklefrancois:image_uri_fix
Open

Uses decoded URI directly for filename extraction#521
mklefrancois wants to merge 8 commits intosyoyo:releasefrom
mklefrancois:image_uri_fix

Conversation

@mklefrancois
Copy link
Copy Markdown

The GetBaseFilename function was previously used to extract the base filename from the decoded URI. However, the decoded URI already represents the desired filename. This allow to preserve the sub-directory of the original URI.

See issue: https://github.com/syoyo/tinygltf/issues/520

@syoyo syoyo requested a review from Copilot July 17, 2025 12:23

This comment was marked as outdated.

@mklefrancois
Copy link
Copy Markdown
Author

Hi, does this PR looks good ?

@syoyo
Copy link
Copy Markdown
Owner

syoyo commented Jul 25, 2025

please answer Copilot's comment

@syoyo
Copy link
Copy Markdown
Owner

syoyo commented Jul 28, 2025

Could you please add unit test code to tests/tester.cc?

@mklefrancois
Copy link
Copy Markdown
Author

I have added a unit test and found that when saving the .gltf to a different path, the sub-directory wasn't created and therefore failing to write the scene properly. There is a change to the PR where sub-directories will be created if needed. With this change, the unit test passes.

@syoyo
Copy link
Copy Markdown
Owner

syoyo commented Jul 28, 2025

Thank you! Let me give time to review PR

@mklefrancois
Copy link
Copy Markdown
Author

Hi, just checking for the status of the PR.
Kind regards
Martin-Karl

@syoyo syoyo requested a review from Copilot August 16, 2025 16:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modifies the image filename handling in the TinyGLTF library to preserve subdirectory paths when writing image files. Instead of extracting only the base filename from decoded URIs, the code now uses the complete decoded URI as the filename, allowing subdirectories to be preserved.

  • Replaces GetBaseFilename(decoded_uri) with direct use of decoded_uri for filename extraction
  • Adds a new CreateDirectories function to recursively create directory structures
  • Integrates directory creation into the file writing workflow to support subdirectory preservation

Reviewed Changes

Copilot reviewed 4 out of 7 changed files in this pull request and generated 5 comments.

File Description
tiny_gltf.h Core implementation changes including new directory creation function and modified filename handling
tests/tester.cc Test case to verify subdirectory path preservation functionality
models/CubeWithSubDir/README.md Documentation for test model with subdirectory structure
models/CubeWithSubDir/Cube.gltf Test model file containing image URIs with subdirectory paths

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@syoyo
Copy link
Copy Markdown
Owner

syoyo commented Aug 16, 2025

there is also unresolved unresolved review.

The GetBaseFilename function was previously used to extract the base filename from the decoded URI. However, the decoded URI already represents the desired filename. This allow to preserve the sub-directory of the original URI.
Ensures that image URI paths, including subdirectories, are correctly preserved when writing glTF files. This prevents issues where texture paths are flattened, leading to incorrect file access.

Adds recursive directory creation to ensure that subdirectories specified in image URIs are created during the write process.

Includes a new test case to verify the correct preservation of image URI paths with subdirectories.
@mklefrancois
Copy link
Copy Markdown
Author

/copilot review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 17 changed files in this pull request and generated 9 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mklefrancois and others added 4 commits December 21, 2025 10:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@syoyo
Copy link
Copy Markdown
Owner

syoyo commented Jan 13, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants