diff options
author | infirit <[email protected]> | 2014-11-23 00:06:52 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2014-11-23 00:06:52 +0100 |
commit | d80298f683bc5f8461a06212d0564523146fb6ed (patch) | |
tree | 4e1b815ae0eff4c19340410a0fd7d115fb5e46b0 /src/fr-window.c | |
parent | e2cd8acb8233e57847b7486b1096efe86368c44c (diff) | |
download | engrampa-d80298f683bc5f8461a06212d0564523146fb6ed.tar.bz2 engrampa-d80298f683bc5f8461a06212d0564523146fb6ed.tar.xz |
engrampa doesn't delete directories w/ files within
consider '/path/to/dir' and '/path/to/dir/' the same path
Based on FR commit: 238b11888a6d88af70d056963257a7bf2cf4192c
From: Paolo Bacchilega <[email protected]>
Gnome bug: https://bugzilla.gnome.org/show_bug.cgi?id=632339
closes #69
Diffstat (limited to 'src/fr-window.c')
-rw-r--r-- | src/fr-window.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/fr-window.c b/src/fr-window.c index fb5da06..cec29a2 100644 --- a/src/fr-window.c +++ b/src/fr-window.c @@ -3289,6 +3289,9 @@ action_performed (FrArchive *archive, /* -- selections -- */ +#undef DEBUG_GET_DIR_LIST_FROM_PATH + + static GList * get_dir_list_from_path (FrWindow *window, char *path) @@ -3305,9 +3308,31 @@ get_dir_list_from_path (FrWindow *window, dirname_l = strlen (dirname); for (i = 0; i < window->archive->command->files->len; i++) { FileData *fd = g_ptr_array_index (window->archive->command->files, i); + gboolean matches = FALSE; - if (strncmp (dirname, fd->full_path, dirname_l) == 0) +#ifdef DEBUG_GET_DIR_LIST_FROM_PATH + g_print ("%s <=> %s (%d)\n", dirname, fd->full_path, dirname_l); +#endif + + if (fd->dir) { + int full_path_l = strlen (fd->full_path); + if ((full_path_l == dirname_l - 1) && (strncmp (dirname, fd->full_path, full_path_l) == 0)) + /* example: dirname is '/path/to/dir/' and fd->full_path is '/path/to/dir' */ + matches = TRUE; + else if (strcmp (dirname, fd->full_path) == 0) + matches = TRUE; + } + + if (! matches && strncmp (dirname, fd->full_path, dirname_l) == 0) { + matches = TRUE; + } + + if (matches) { +#ifdef DEBUG_GET_DIR_LIST_FROM_PATH + g_print ("`-> OK\n"); +#endif list = g_list_prepend (list, g_strdup (fd->original_path)); + } } g_free (dirname); |