![]() |
|
File system routines - al_get_path_tail() returning wrong path component |
TeaRDoWN
Member #8,518
April 2007
![]() |
EDIT: Solved! Years back I made a function that check for which mods are available in subfolders under a subfolder called "Mods" in my game's project directory. When finding a mod the name is stored and used for loading different assets. Here's a simplified code snippet of what I am doing and the results I get: 1ALLEGRO_PATH *ap;
2char *projectPath;
3char *projectName;
4...
5while(true)
6{
7 ap = createAnAllegroPathToEachSubfolderUnderTheModsFolder();
8 ...
9 sprintf(modPath, "%s\\file.txt", al_path_cstr(ap, ALLEGRO_NATIVE_PATH_SEP));
10 ...
projectPath will contain the correct full path "C:\\Projects\\MyProject\\Mods\\Zelda\\file.txt". However when using al_get_path_tail() I do not get the last component in the path but the second to last: projectName will contain "Mods" instead of "Zelda". Same result will happen when using al_get_path_component() with -1 (first from right) as component id: projectName will again contain "Mods" instead of "Zelda". It's like the last component of the path is ignored but back in 2003 when I used the code it worked. The only thing I can think of that has changed is my Windows version. Trying to find a newer version of Allegro (5.2.5) to try that but no luck finding binaries of this (yet). --- EDIT: I just noticed that my ALLEGRO_PATH *get_next_subdirectory_in_directory() function used: So a bug due to me. However I don't think I've touched this code since 2013...aaand I think it worked back then. But who remembers. Oh well, problem solved! |
|