Skip to content
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

SDL_GlobStorageDirectory doesn't work with storage prefixes #11427

Open
WilliamBundy opened this issue Nov 8, 2024 · 0 comments
Open

SDL_GlobStorageDirectory doesn't work with storage prefixes #11427

WilliamBundy opened this issue Nov 8, 2024 · 0 comments
Milestone

Comments

@WilliamBundy
Copy link

When using SDL_Storage, I found that SDL_GlobStorageDirectory didn't work unless I set my override prefix to an empty string and set the cwd to the base path (either by chdir or just launching the game from the correct folder). I was confused as to why neither NULL nor SDL_GetBasePath() worked as arguments. I first noticed this on mac, but it occurred when I set up a new windows build as well.

My usage of SDL_Storage looks like this

SDL_Storage* titleStorage = SDL_OpenTitleStorage(NULL, 0);
int numFiles = 0; 
char** files = SDL_GlobStorageDirectory(titleStorage, ".", "*.spv", 0, &numFiles);
assert(files && numFiles != 0); // there are definitely a few .spv files in the directory

After doing some digging, it seems like the issue is most immediately in GlobDirectoryCallback where the callback userdata's basedirlen field is set to the length of "." + 1 in SDL_InternalGlobDirectory, but in GENERIC_EnumerateStorageDirectory, the path is expanded with the storage's basepath, so most of the basedir portion of the path is passed to WildcardMatch, which immediately fails when it sees a '/'.

I was hoping this would be a small fix, but as far as I can tell, there's nowhere in the call stack that knows that we are doing directory enumeration with GlobDirCallbackData and knows that we're using a storage object except SDL_GlobStorageDirectory, but that doesn't have access to the GENERIC_INTERNAL_GetCreateFullPath, so as far as I can tell, some rearchitecting is required to pass this information around correctly. I believe the way GlobDirCallbackData is written is to support matching patterns in subpaths, but given how WildcardMatch seems to reject any '/' characters, that might be a separate but related issue.

@slouken slouken added this to the 3.2.0 milestone Nov 8, 2024
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

No branches or pull requests

2 participants