aboutsummaryrefslogtreecommitdiffstats
path: root/src/fm.c
diff options
context:
space:
mode:
authorverdant <im@verdant.ee>2026-08-03 15:55:30 +0800
committerverdant <im@verdant.ee>2026-08-03 15:56:59 +0800
commit2a0212fdd4eaa03cd54f997878810672b34b2f9c (patch)
tree0c2ca390575bc0ab455de73cdae4a54f0be66be7 /src/fm.c
parent4e7e1e21b3eb29a5505dc69f668cf5f9481bd7d5 (diff)
downloadsf-2a0212fdd4eaa03cd54f997878810672b34b2f9c.tar.gz
sf-2a0212fdd4eaa03cd54f997878810672b34b2f9c.zip
Implement directory creating
Diffstat (limited to 'src/fm.c')
-rw-r--r--src/fm.c24
1 files changed, 24 insertions, 0 deletions
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 <curses.h>
#include <dirent.h>
@@ -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;
+}