Commit Diff


commit - ee9a7a2aba7669aae9ad11f8dc95eb3923e23328
commit + 8a757b0f606a31a4db5390507eb980bbffa8b5c4
blob - b337b89743e94f41d665dc8c9912085140f0c453
blob + 2c91a6725a2d4530a6fbdb59478164f4f50206fe
--- rover.c
+++ rover.c
@@ -11,6 +11,7 @@
 #include <fcntl.h>      /* open() */
 #include <sys/wait.h>   /* waitpid() */
 #include <signal.h>     /* struct sigaction, sigaction() */
+#include <errno.h>
 #include <curses.h>
 
 #include "config.h"
@@ -568,11 +569,18 @@ static int adddir(const char *path) {
     return mkdir(path, st.st_mode);
 }
 static int movfile(const char *srcpath) {
+    int ret;
     char dstpath[FILENAME_MAX];
 
     strcpy(dstpath, CWD);
     strcat(dstpath, srcpath + strlen(rover.marks.dirpath));
-    return rename(srcpath, dstpath);
+    ret = rename(srcpath, dstpath);
+    if (ret < 0 && errno == EXDEV) {
+        ret = cpyfile(srcpath);
+        if (ret < 0) return ret;
+        ret = delfile(srcpath);
+    }
+    return ret;
 }
 
 /* Do a fork-exec to external program (e.g. $EDITOR). */