From 2a0212fdd4eaa03cd54f997878810672b34b2f9c Mon Sep 17 00:00:00 2001 From: verdant Date: Mon, 3 Aug 2026 15:55:30 +0800 Subject: Implement directory creating --- src/fm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/fm.c') diff --git a/src/fm.c b/src/fm.c index 9f0bbe8..0d59ab9 100644 --- a/src/fm.c +++ b/src/fm.c @@ -4,6 +4,7 @@ #include "err.h" #include "log.h" #include "process.h" +#include "utils.h" #include "wm.h" #include #include @@ -491,3 +492,26 @@ draw_status_bar(window *bar_win, const char *cwd, char permission[11]) permission); wattroff(bar_win->win, COLOR_PAIR(COLOR_PAIR_FM_STATUS_BAR)); } + +int +new_dir(fm_info *info) +{ + const char *cwd = info->cwd; + char buf[PATH_MAX] = {0}; + if (get_input("Directory name: ", buf) != 0) { + return -1; + } + + char *path; + if (asprintf(&path, "%s/%s", cwd, buf) < 0) + return -1; + + if (mkdir(path, 0755) != 0) { + return -1; + } + + free(path); + need_redraw = true; + fm_getdir(info->cur, info->cwd); + return 0; +} -- cgit v1.2.3