diff options
Diffstat (limited to 'src/fm.c')
| -rw-r--r-- | src/fm.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -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; +} |
