Also support '\' in paths
authorRobert Pengelly <robertapengelly@hotmail.com>
Sun, 31 Aug 2025 09:54:14 +0000 (10:54 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Sun, 31 Aug 2025 09:54:14 +0000 (10:54 +0100)
e2cp.c
e2md.c

diff --git a/e2cp.c b/e2cp.c
index bdea24fe74720961a149d0038360eb63da0e3d69..28caf180ebc05ac245723f4a334c5fd3bf85c950 100644 (file)
--- a/e2cp.c
+++ b/e2cp.c
@@ -311,7 +311,7 @@ static unsigned long find_entry (struct filesystem *fs, unsigned long nod, const
 
 #define     CB_SIZE                     (COPY_BLOCKS * BLOCKSIZE)
 
-signed long read_cb (struct filesystem *fs, struct inode_pos *ipos, signed long size, void *data) {
+static signed long read_cb (struct filesystem *fs, struct inode_pos *ipos, signed long size, void *data) {
 
     signed long remaining_size = size;
     
@@ -362,7 +362,7 @@ static void write_file (struct filesystem *fs, struct inode *node, struct inode_
 
 }
 
-unsigned long mkfile_fs (struct filesystem *fs, unsigned long parent_nod, const char *name, void *data, unsigned long size, unsigned short uid, unsigned short gid, unsigned long ctime, unsigned long mtime) {
+static unsigned long mkfile_fs (struct filesystem *fs, unsigned long parent_nod, const char *name, void *data, unsigned long size, unsigned short uid, unsigned short gid, unsigned long ctime, unsigned long mtime) {
 
     unsigned long nod;
     
@@ -700,12 +700,12 @@ static int check_overwrite (const char *fn) {
 
 }
 
-static void copy_file (struct filesystem *fs, FILE *fp, unsigned long parent_nod, char *fn) {
+static void copy_file (struct filesystem *fs, FILE *fp, unsigned long parent_nod, char *target) {
 
     unsigned long bytes = 0, timestamp = time (0), nod;
-    char *basename = fn, *p;
+    char *basename = target, *p;
     
-    if ((p = strrchr (fn, '/')) || (p = strrchr (fn, '\\'))) {
+    if ((p = strrchr (target, '/')) || (p = strrchr (target, '\\'))) {
         basename = (p + 1);
     }
     
diff --git a/e2md.c b/e2md.c
index c2347b1e9ab7b30176ed8a1afcfbbddfc15c375e..f24935a7bb594c095505fbd4467e55ace4697aa0 100644 (file)
--- a/e2md.c
+++ b/e2md.c
@@ -297,19 +297,18 @@ static unsigned long find_entry (struct filesystem *fs, unsigned long nod, const
 
 static void walk_dir (struct filesystem *fs, char *dirname) {
 
-    unsigned long parent_nod = EXT2_ROOT_INO;
-    unsigned long timestamp = time (0);
+    unsigned long parent_nod = EXT2_ROOT_INO, timestamp = time (0);
+    char *p1 = dirname, *p2, saved_ch;
     
-    char *p1 = dirname, *p2;
-    
-    while (*p1 && *p1 == '/') {
+    while (*p1 && (*p1 == '/' || *p1 == '\\')) {
         p1++;
     }
     
     if (*p1) {
     
-        for (; (p2 = strchr (p1, '/')); p1 = p2 + 1) {
+        for (; (p2 = strchr (p1, '/')) || (p2 = strchr (p1, '\\')); p1 = p2 + 1) {
         
+            saved_ch = *p2;
             *p2 = '\0';
             
             if (strlen (p1) >= 14) {
@@ -320,12 +319,12 @@ static void walk_dir (struct filesystem *fs, char *dirname) {
             
                 report_at (program_name, 0, REPORT_ERROR, "cannot access '%s'", dirname);
                 
-                *p2 = '/';
+                *p2 = saved_ch;
                 return;
             
             }
             
-            *p2 = '/';
+            *p2 = saved_ch;
         
         }