[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Removing remove bug



> Remove bug--[snip]
Ah.  Xwpe uses rename() to move the file into the wastebasket but rename()
generates an error when used across partitions.  Thus proving you should
always check return codes.  The continual "wait" mouse cursor is caused
by the changes I made in mouse cursor handling.  The included patch fixes
both of these problems.  There is still a slight bug in that certain
operations such as remove will forget what the mouse cursor was and return
to the editor cursor.

Dennis Payne
payned@rpi.edu


--- ../xwpe-1.5.5a/we_fl_unix.c	Tue Mar 17 22:38:13 1998
+++ we_fl_unix.c	Mon Mar 23 23:15:13 1998
@@ -1215,14 +1215,17 @@
       {  e_ret_wastefile(file, tmp);
 	 ret = strlen(tmp);
 	 if(strncmp(tmp, file, ret))
-	 {  e_rename(file, tmp, f);   return(0);  }
+	 {  e_rename(file, tmp, f);  }
       }
-      if(f->ed->flopt & 0200)
-      {  sprintf(tmp, "Remove File:\n%s", file);
-	 ret = e_message(1, tmp, f);
+      else
+      {
+         if(f->ed->flopt & 0200)
+         {  sprintf(tmp, "Remove File:\n%s", file);
+	    ret = e_message(1, tmp, f);
+         }
+         else ret = 'Y';
+         if(ret == 'Y') remove(file);
       }
-      else ret = 'Y';
-      if(ret == 'Y') remove(file);
    }
    else e_remove_dir(file, f->ed->fd.file, f, 0);
    WpeMouseRestoreShape();
@@ -1438,7 +1441,14 @@
       {  if(sw == 1) fk_copy(file, newname);
 #ifndef DJGPP
 	 else if(sw == 2) fk_link(file, newname, f->ed->flopt & 0400);
-	 else if(sw == 0 && ln < 0) fk_rename(file, newname);
+	 else if(sw == 0 && ln < 0)
+         {
+            if ((fk_rename(file, newname) == -1) && (errno == EXDEV))
+            {
+             fk_copy(file, newname);
+             remove(file);
+            }
+         }
 	 else if(sw == 0)
 	 {  tmpl[ln] = '\0';
 	    for( ; ln >= 0 && tmpl[ln] != DIRC; ln--);