summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2010-10-31 14:22:40 +0000
committerTeruaki Kawashima <teru@rockbox.org>2010-10-31 14:22:40 +0000
commita177e13ee02f671d2476a2f68aeafbae49ffda69 (patch)
tree4b41aef15ea6ebd2a8574b7d65701bac5ef8f224
parente20fc429a8b0162d48242385ae98ae6aa405a912 (diff)
downloadrockbox-a177e13ee02f671d2476a2f68aeafbae49ffda69.tar.gz
rockbox-a177e13ee02f671d2476a2f68aeafbae49ffda69.zip
disktidy: handles user abort properly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28418 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/disktidy.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c
index 92232bf17a..23bf0d18c9 100644
--- a/apps/plugins/disktidy.c
+++ b/apps/plugins/disktidy.c
@@ -267,7 +267,6 @@ enum tidy_return tidy_removedir(char *path, int *path_length)
267 /* silent error */ 267 /* silent error */
268 continue; 268 continue;
269 269
270
271 struct dirinfo info = rb->dir_get_info(dir, entry); 270 struct dirinfo info = rb->dir_get_info(dir, entry);
272 if (info.attribute & ATTR_DIRECTORY) 271 if (info.attribute & ATTR_DIRECTORY)
273 { 272 {
@@ -275,7 +274,7 @@ enum tidy_return tidy_removedir(char *path, int *path_length)
275 if ((rb->strcmp(entry->d_name, ".") != 0) && \ 274 if ((rb->strcmp(entry->d_name, ".") != 0) && \
276 (rb->strcmp(entry->d_name, "..") != 0)) 275 (rb->strcmp(entry->d_name, "..") != 0))
277 { 276 {
278 tidy_removedir(path, path_length); 277 status = tidy_removedir(path, path_length);
279 } 278 }
280 } 279 }
281 else 280 else
@@ -284,7 +283,7 @@ enum tidy_return tidy_removedir(char *path, int *path_length)
284 removed++; 283 removed++;
285 rb->remove(path); 284 rb->remove(path);
286 } 285 }
287 286
288 /* restore path */ 287 /* restore path */
289 tidy_path_remove_entry(path, old_path_length, path_length); 288 tidy_path_remove_entry(path, old_path_length, path_length);
290 } 289 }
@@ -307,7 +306,6 @@ enum tidy_return tidy_clean(char *path, int *path_length)
307 struct dirent *entry; 306 struct dirent *entry;
308 enum tidy_return status = TIDY_RETURN_OK; 307 enum tidy_return status = TIDY_RETURN_OK;
309 int button; 308 int button;
310 int del; /* has the item been deleted */
311 DIR *dir; 309 DIR *dir;
312 int old_path_length = *path_length; 310 int old_path_length = *path_length;
313 311
@@ -344,8 +342,6 @@ enum tidy_return tidy_clean(char *path, int *path_length)
344 if ((rb->strcmp(entry->d_name, ".") != 0) && \ 342 if ((rb->strcmp(entry->d_name, ".") != 0) && \
345 (rb->strcmp(entry->d_name, "..") != 0)) 343 (rb->strcmp(entry->d_name, "..") != 0))
346 { 344 {
347 del = 0;
348
349 /* get absolute path */ 345 /* get absolute path */
350 /* returns an error if path is too long */ 346 /* returns an error if path is too long */
351 if(!tidy_path_append_entry(path, entry, path_length)) 347 if(!tidy_path_append_entry(path, entry, path_length))
@@ -355,11 +351,9 @@ enum tidy_return tidy_clean(char *path, int *path_length)
355 if (tidy_remove_item(entry->d_name, info.attribute)) 351 if (tidy_remove_item(entry->d_name, info.attribute))
356 { 352 {
357 /* delete dir */ 353 /* delete dir */
358 tidy_removedir(path, path_length); 354 status = tidy_removedir(path, path_length);
359 del = 1;
360 } 355 }
361 356 else
362 if (del == 0)
363 { 357 {
364 /* dir not deleted so clean it */ 358 /* dir not deleted so clean it */
365 status = tidy_clean(path, path_length); 359 status = tidy_clean(path, path_length);
@@ -372,7 +366,6 @@ enum tidy_return tidy_clean(char *path, int *path_length)
372 else 366 else
373 { 367 {
374 /* file */ 368 /* file */
375 del = 0;
376 if (tidy_remove_item(entry->d_name, info.attribute)) 369 if (tidy_remove_item(entry->d_name, info.attribute))
377 { 370 {
378 /* get absolute path */ 371 /* get absolute path */
@@ -384,8 +377,7 @@ enum tidy_return tidy_clean(char *path, int *path_length)
384 removed++; /* increment removed files counter */ 377 removed++; /* increment removed files counter */
385 /* delete file */ 378 /* delete file */
386 rb->remove(path); 379 rb->remove(path);
387 del = 1; 380
388
389 /* restore path */ 381 /* restore path */
390 tidy_path_remove_entry(path, old_path_length, path_length); 382 tidy_path_remove_entry(path, old_path_length, path_length);
391 } 383 }