Mercurial > geeqie.yaz
comparison src/utilops.c @ 44:458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
* utilops.[ch] (file_util_rename_dir): New utility to rename a folder,
does proper checking for existing folder to avoid clobbering an
existing folder.
* view_dir_list.c, view_dir_tree.c: Use new utility above when renaming
a folder to fix possible clobbering of an existing folder with the
same name as the requested name.
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
##### an offical release when making enhancements and translation updates. #####
author | gqview |
---|---|
date | Wed, 18 May 2005 23:52:16 +0000 |
parents | 606fcf461a68 |
children | ebbff299ad0d |
comparison
equal
deleted
inserted
replaced
43:ee03f36e9e4b | 44:458e396d3f35 |
---|---|
2451 gtk_widget_show(fd->entry); | 2451 gtk_widget_show(fd->entry); |
2452 | 2452 |
2453 gtk_widget_show(GENERIC_DIALOG(fd)->dialog); | 2453 gtk_widget_show(GENERIC_DIALOG(fd)->dialog); |
2454 } | 2454 } |
2455 | 2455 |
2456 gint file_util_rename_dir(const gchar *old_path, const gchar *new_path, GtkWidget *parent) | |
2457 { | |
2458 const gchar *old_name; | |
2459 const gchar *new_name; | |
2460 | |
2461 if (!old_path || !new_path || !isdir(old_path)) return FALSE; | |
2462 | |
2463 old_name = filename_from_path(old_path); | |
2464 new_name = filename_from_path(new_path); | |
2465 | |
2466 if (isdir(new_path)) | |
2467 { | |
2468 gchar *text = g_strdup_printf(_("The folder:\n%s\nalready exists."), new_name); | |
2469 file_util_warning_dialog(_("Folder exists"), text, GTK_STOCK_DIALOG_INFO, parent); | |
2470 g_free(text); | |
2471 | |
2472 return FALSE; | |
2473 } | |
2474 | |
2475 if (isname(new_path)) | |
2476 { | |
2477 gchar *text = g_strdup_printf(_("The path:\n%s\nalready exists as a file."), new_name); | |
2478 file_util_warning_dialog(_("Rename failed"), text, GTK_STOCK_DIALOG_INFO,parent); | |
2479 g_free(text); | |
2480 | |
2481 return FALSE; | |
2482 } | |
2483 | |
2484 if (!rename_file(old_path, new_path)) | |
2485 { | |
2486 gchar *text = g_strdup_printf(_("Failed to rename %s to %s."), old_name, new_name); | |
2487 file_util_warning_dialog("Rename failed", text, GTK_STOCK_DIALOG_ERROR, parent); | |
2488 g_free(text); | |
2489 | |
2490 return FALSE; | |
2491 } | |
2492 | |
2493 return TRUE; | |
2494 } | |
2495 |