Prevent "mv dir dir/subdir" as it is not catched by ntfs.sys of NT-5.1sp1.
authorshort <>
Sat, 6 Dec 2003 18:50:37 +0000 (18:50 +0000)
committershort <>
Sat, 6 Dec 2003 18:50:37 +0000 (18:50 +0000)
 - Bugreport by Ulrich Mueller.

src/libcaptive/client/file-parent.c

index 1d0da83..c7d999f 100644 (file)
@@ -25,6 +25,8 @@
 #include "vfs-parent.h"
 #include "reactos/ntos/types.h"        /* for ULONG */
 #include "parent-connector.h"
+#include "captive/client.h"    /* for captive_path_normalize() */
+#include <ctype.h>
 
 
 static gpointer captive_file_parent_object_parent_class=NULL;
@@ -520,12 +522,31 @@ static GnomeVFSResult captive_file_parent_move
 CaptiveFileParentObject *captive_file_parent_object_old;
 GnomeVFSResult r;
 gint retried=0;
+gchar *chksub_pathname_old,*chksub_pathname_new,*chksub_s_old,*chksub_s_new;
 
        g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_object_old),GNOME_VFS_ERROR_BAD_PARAMETERS);
        g_return_val_if_fail(pathname_new!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
 
        captive_file_parent_object_old=CAPTIVE_FILE_PARENT_OBJECT(captive_file_object_old);
 
+       /* Prevent "mv dir dir/subdir" as it is not catched by ntfs.sys of NT-5.1sp1. */
+       /* FIXME: UTF8/Unicode */
+       /* FIXME: Move to 'CaptiveFileSlaveObject' but it has no '->pathname' stored now! */
+       chksub_pathname_old=captive_path_normalize(captive_file_parent_object_old->pathname);
+       chksub_pathname_new=captive_path_normalize(pathname_new);
+       for (
+                       chksub_s_old=chksub_pathname_old,chksub_s_new=chksub_pathname_new;
+                       *chksub_s_old && *chksub_s_new && tolower(*chksub_s_old)==tolower(*chksub_s_new);
+                       chksub_s_old++,chksub_s_new++);
+       g_assert(chksub_s_old>chksub_pathname_old);
+       g_assert(chksub_s_new>chksub_pathname_new);
+       if (!*chksub_s_old && (!*chksub_s_new || *chksub_s_new=='/'))
+               return GNOME_VFS_ERROR_DIRECTORY_BUSY;
+       if (!*chksub_s_new && (!*chksub_s_old || *chksub_s_old=='/'))
+               return GNOME_VFS_ERROR_DIRECTORY_BUSY;
+       g_free(chksub_pathname_old);
+       g_free(chksub_pathname_new);
+
        do {
                if (GNOME_VFS_OK!=(r=captive_parent_connector_open(CAPTIVE_PARENT_CONNECTOR(captive_file_parent_object_old))))
                        return r;