fix gdi track parsing in unixx

Same problem as https://github.com/libretro/reicast-emulator/pull/24

in unix that iteration would not work if the path of the original .gdi file (where we are finding the 'parent directory') was:

1. not existent, ie a gdi on the same directory as the current. It was iterating until the index 3 and stop there. Disaster strikes later ofc, if the first characters weren't C:\ or other thing like that.
2. in a relative subdirectory that is 'small enough' ie: a/crazy-taxi.gdi. In this case the last '/' wouldn't be found, the derived string would be 'crazy-taxi.gdi' and the file not found ofc.

Anyway, this can be solved simply by searching the whole string and using a signed integer. It will go up to -1, stop iteration and increase to 0 on the len++.

Dunno if using relative subdirectories for the tracks on *other* platforms works because of the path separator being different from what's inside the gdi but with this code fixed it works on linux with / at least.
This commit is contained in:
i30817 2018-03-25 18:53:18 +01:00 committed by GitHub
parent 9adadd5d7a
commit 3fdd7f50ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -36,9 +36,9 @@ Disc* load_gdi(const char* file)
strncpy(path, file, sizeof(path));
path[sizeof(path) - 1] = '\0';
size_t len = strlen(path);
ssize_t len = strlen(path);
while (len>2)
while (len>=0)
{
if (path[len]=='\\' || path[len]=='/')
break;
@ -118,4 +118,4 @@ Disc* gdi_parse(const char* file)
void iso_term()
{
}
}