From 9ad19594dfc9eadd93a788dcd387409299ee7498 Mon Sep 17 00:00:00 2001 From: verdant Date: Wed, 5 Aug 2026 21:19:28 +0800 Subject: Implement remove file or directory --- src/fm.c | 17 +++++++++++++++++ src/fm.h | 1 + 2 files changed, 18 insertions(+) (limited to 'src') diff --git a/src/fm.c b/src/fm.c index 1af1586..06a980c 100644 --- a/src/fm.c +++ b/src/fm.c @@ -586,3 +586,20 @@ fm_rename(fm_info *info) return 0; } +/* + REATURN VALUE: + -1: error + -2: cancel + */ +int +fm_rm(const char *path) +{ + if (!path) { + return -1; + } + + if (y_or_n("Delete it?")) + return (remove(path) == 0) ? 0 : -1; + else + return -2; +} diff --git a/src/fm.h b/src/fm.h index 239c6b9..06c065e 100644 --- a/src/fm.h +++ b/src/fm.h @@ -70,4 +70,5 @@ void get_permission(mode_t mode, char *str); int new_dir(fm_info *info); +int fm_rm(const char *path); #endif /* SF_FM_H */ -- cgit v1.2.3