avoid rename ..
authorLaurent Mazet <mazet@softndesign.org>
Sun, 19 Jan 2025 15:29:21 +0000 (16:29 +0100)
committerLaurent Mazet <mazet@softndesign.org>
Sun, 19 Jan 2025 15:29:21 +0000 (16:29 +0100)
fm.c

diff --git a/fm.c b/fm.c
index 7ed231034f00eb37bd50f9dcdb890a8b338cbd21..e41f3a3f6db0b5003c4328d1ec2b71b0e264ab94 100644 (file)
--- a/fm.c
+++ b/fm.c
@@ -401,27 +401,29 @@ int main (int argc, char *argv[])
                 break;
             case ALT_R: /* rename */
                 current = list[panel]->tab + windir[panel]->index;
-                len = (strlen (current->name) > MAXFNAME * 80 / 100) ? 2 * MAXFNAME + 1: MAXFNAME + 1;
-                string = getwindow ("Rename", winscreen, MAXFNAME / 2, len, current->name);
-                if (string) {
-                    if (strchr (string, *SEPARATOR) != NULL) {
-                        char *buf = strdupcat ("Can't rename file to '", string, "'", NULL);
-                        errorwindow (buf, winscreen);
-                        free (buf);
-                    } else {
-                        char *src = newfilename (dirname[panel], current->name);
-                        char *dest = newfilename (dirname[panel], string);
-                        char *msg = processmove (dest, src);
-                        if (msg) {
-                            errorwindow (msg, winscreen);
-                            free (msg);
+                if (strcmp (current->name, "..") != 0) {
+                    len = (strlen (current->name) > MAXFNAME * 80 / 100) ? 2 * MAXFNAME + 1: MAXFNAME + 1;
+                    string = getwindow ("Rename", winscreen, MAXFNAME / 2, len, current->name);
+                    if (string) {
+                        if (strchr (string, *SEPARATOR) != NULL) {
+                            char *buf = strdupcat ("Can't rename file to '", string, "'", NULL);
+                            errorwindow (buf, winscreen);
+                            free (buf);
+                        } else {
+                            char *src = newfilename (dirname[panel], current->name);
+                            char *dest = newfilename (dirname[panel], string);
+                            char *msg = processmove (dest, src);
+                            if (msg) {
+                                errorwindow (msg, winscreen);
+                                free (msg);
+                            }
+                            free (src);
+                            free (dest);
+                            freelist (list[panel]);
+                            list[panel] = NULL;
                         }
-                        free (src);
-                        free (dest);
-                        freelist (list[panel]);
-                        list[panel] = NULL;
+                        free (string);
                     }
-                    free (string);
                 }
                 break;
             case ALT_S: /* select */