From 70b27796547433291e376eee8a8ba50d97a44f85 Mon Sep 17 00:00:00 2001 From: Sijmen Schoon Date: Tue, 12 Jul 2016 23:35:20 +0200 Subject: [PATCH] Add a failsave to the parent directory code --- src/windows/loadsave.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/windows/loadsave.c b/src/windows/loadsave.c index 5dc6c7aa48..373919f251 100644 --- a/src/windows/loadsave.c +++ b/src/windows/loadsave.c @@ -583,10 +583,15 @@ static void window_loadsave_populate_list(rct_window *w, int includeNewItem, con // Remove everything past the now last separator char *ch = strrchr(_parentDirectory, separator); - if (ch != NULL) + if (ch != NULL) { *(ch + 1) = '\0'; - else + } else if (drives) { + // If on Windows, clear the entire path to show the drives _parentDirectory[0] = '\0'; + } else { + // Else, go to the root directory + sprintf(_parentDirectory, "%c", separator); + } // Disable the Up button if the current directory is the root directory if (str_is_null_or_empty(_parentDirectory) && !drives)