Skip to content

Commit

Permalink
Open file dialog shoud not clobber CWD
Browse files Browse the repository at this point in the history
Now restores the previous CWD after the dialog closes.
  • Loading branch information
kometbomb committed May 4, 2017
1 parent 4397450 commit c67ccb6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/diskop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down Expand Up @@ -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);
}

0 comments on commit c67ccb6

Please sign in to comment.