From 3fdd7f50ea238f6a62952ecea18c625a58f893ef Mon Sep 17 00:00:00 2001 From: i30817 Date: Sun, 25 Mar 2018 18:53:18 +0100 Subject: [PATCH] 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. --- core/imgread/gdi.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/imgread/gdi.cpp b/core/imgread/gdi.cpp index 5eaf87859..e1f650e93 100644 --- a/core/imgread/gdi.cpp +++ b/core/imgread/gdi.cpp @@ -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() { -} \ No newline at end of file +}