sfm

simple file manager
git clone git://git.afify.dev/sfm
Log | Files | Refs | README | LICENSE

commit 202031b4d5d1090407a5c9069bd653407b9fc8dd
parent 201b78e5fd3c7461559e92fde216da921d93c813
Author: afify <hassan@afify.dev>
Date:   Sun,  6 Dec 2020 07:43:40 +0300

[fix] renaming fullpath

Diffstat:
Msfm.c | 16+++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/sfm.c b/sfm.c @@ -1621,19 +1621,25 @@ get_path_hdir(int Ndir) static void rname(void) { - char *new_name; - new_name = ecalloc(MAX_N, sizeof(char)); + char new_name[MAX_P]; + char *input_name; - if (get_usrinput(new_name, MAX_N, "rename: %s", basename(CURSOR_NAME)) < 0) { - free(new_name); + input_name = ecalloc(MAX_N, sizeof(char)); + + if (get_usrinput(input_name, MAX_N, "rename: %s", basename(CURSOR_NAME)) < 0) { + free(input_name); return; } + strcpy(new_name, cpane->dirn); + strcat(new_name, "/"); + strcat(new_name, input_name); + char *rename_cmd[] = { "mv", CURSOR_NAME, new_name, NULL }; if (spawn(rename_cmd, NULL) < 0) print_error(strerror(errno)); - free(new_name); + free(input_name); } static void