diff --git a/src/diskop.c b/src/diskop.c index 9822a4f7..87f14f79 100644 --- a/src/diskop.c +++ b/src/diskop.c @@ -813,10 +813,13 @@ void open_data(void *type, void *action, void *_ret) def = _def; } - char filename[5000]; + char filename[5000], previous_cwd[5000]; FILE *f = NULL; SDL_RWops *rw = NULL; + // Save current cwd + getcwd(previous_cwd, sizeof(previous_cwd)); + if (mused.previous_filebox_path[t][0]) chdir(mused.previous_filebox_path[t]); @@ -886,5 +889,8 @@ void open_data(void *type, void *action, void *_ret) else if (ret) *ret = 0; + // Restore previous cwd + chdir(previous_cwd); + change_mode(mused.mode); }