From bc186c1a6bd1f40739147b1ae6a388b7383764cb Mon Sep 17 00:00:00 2001 From: Steve Bavin Date: Tue, 13 May 2008 13:49:50 +0000 Subject: Fix FS#8986, problem where current file changes during deletion. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17494 a1c6a512-1295-4272-9138-f99709370657 --- apps/onplay.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'apps/onplay.c') diff --git a/apps/onplay.c b/apps/onplay.c index a3cbebc2ff..076f90ca59 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -524,13 +524,16 @@ static int remove_dir(char* dirname, int len) /* share code for file and directory deletion, saves space */ static bool delete_handler(bool is_dir) { + char file_to_delete[MAX_PATH]; + strcpy(file_to_delete, selected_file); + const char *lines[]={ ID2P(LANG_REALLY_DELETE), - selected_file + file_to_delete }; const char *yes_lines[]={ ID2P(LANG_DELETED), - selected_file + file_to_delete }; struct text_message message={lines, 2}; @@ -546,16 +549,16 @@ static bool delete_handler(bool is_dir) { char pathname[MAX_PATH]; /* space to go deep */ cpu_boost(true); - strncpy(pathname, selected_file, sizeof pathname); + strncpy(pathname, file_to_delete, sizeof pathname); res = remove_dir(pathname, sizeof(pathname)); cpu_boost(false); } else - res = remove(selected_file); + res = remove(file_to_delete); - if (!res) { + if (!res) onplay_result = ONPLAY_RELOAD_DIR; - } + return false; } -- cgit v1.2.3