summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-file-utilities.c
diff options
context:
space:
mode:
authorPavel Cisler <pavel@eazel.com>2001-02-01 23:33:59 +0000
committerPavel Cisler <pce@src.gnome.org>2001-02-01 23:33:59 +0000
commit8e014624eede6cbf9fb784fc08bcc948b94e810c (patch)
treedf25544cdb07b42b96cdd6200cf57e37dc7ee54e /libnautilus-private/nautilus-file-utilities.c
parentcaada5e909c22e0a1f6cf740b83dbfbed2f7b8fa (diff)
downloadnautilus-8e014624eede6cbf9fb784fc08bcc948b94e810c.tar.gz
reviewed by: Gene Ragan <gzr@eazel.com>
2001-02-01 Pavel Cisler <pavel@eazel.com> reviewed by: Gene Ragan <gzr@eazel.com> Fix 6152 (Dragging a file to the trash will bring up a replace dialog) Fix 5387 (Dragging a file within Trash gives "already exists" error) * libnautilus-extensions/nautilus-drag.c: * libnautilus-extensions/nautilus-drag.h: (nautilus_drag_items_local), (nautilus_drag_items_in_trash): Add more convenience calls for Trash handling. * libnautilus-extensions/nautilus-file-utilities.h: * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_uri_is_in_trash): New convenience call for Trash handling. * libnautilus-extensions/nautilus-file.c: (nautilus_file_is_in_trash): Use the new nautilus_uri_is_in_trash call. * libnautilus-extensions/nautilus-file-operations.c: (nautilus_file_operations_copy_move): Handle the case where a file is dragged into a Trash window or onto a Trash icon as if the "Move to Trash" command was issued - if there is a name conflict with a pre-existing file in the Trash, use a new unique name for the new file. * libnautilus-extensions/nautilus-icon-dnd.c: (nautilus_icon_container_selection_items_local): Handle files in the Trash properly - doing a parent match with the container URI fails for these, special case Trash handling.
Diffstat (limited to 'libnautilus-private/nautilus-file-utilities.c')
-rw-r--r--libnautilus-private/nautilus-file-utilities.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c
index 8c2a759bf..68f891629 100644
--- a/libnautilus-private/nautilus-file-utilities.c
+++ b/libnautilus-private/nautilus-file-utilities.c
@@ -39,6 +39,7 @@
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libgnomevfs/gnome-vfs-xfer.h>
+#include <libgnomevfs/gnome-vfs-find-directory.h>
#include <pthread.h>
#include <pwd.h>
#include <stdlib.h>
@@ -211,6 +212,41 @@ nautilus_uri_is_trash (const char *uri)
|| nautilus_istr_has_prefix (uri, "gnome-trash:");
}
+gboolean
+nautilus_uri_is_in_trash (const char *uri)
+{
+ GnomeVFSURI *vfs_uri, *trash_vfs_uri;
+ gboolean result;
+
+ /* Use a check for the actual trash first so that the trash
+ * itself will be "in trash". There are fancier ways to do
+ * this, but lets start with this.
+ */
+ if (nautilus_uri_is_trash (uri)) {
+ return TRUE;
+ }
+
+ vfs_uri = gnome_vfs_uri_new (uri);
+ if (vfs_uri == NULL) {
+ return FALSE;
+ }
+
+ result = gnome_vfs_find_directory
+ (vfs_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
+ &trash_vfs_uri, FALSE, FALSE, 0777) == GNOME_VFS_OK;
+
+ if (result) {
+ result = gnome_vfs_uri_equal (trash_vfs_uri, vfs_uri)
+ || gnome_vfs_uri_is_parent (trash_vfs_uri, vfs_uri, TRUE);
+ gnome_vfs_uri_unref (trash_vfs_uri);
+ }
+
+ gnome_vfs_uri_unref (vfs_uri);
+
+ return result;
+}
+
+
static gboolean
nautilus_uri_is_local_scheme (const char *uri)
{