aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorverdant <im@verdant.ee>2026-08-05 21:19:28 +0800
committerverdant <im@verdant.ee>2026-08-05 21:19:28 +0800
commit9ad19594dfc9eadd93a788dcd387409299ee7498 (patch)
tree1d23837d0a7c9239d75c9bde45a49736245f81c5 /src
parentcde363621f08a35803ef804f23c44ac27ddacf03 (diff)
downloadsf-9ad19594dfc9eadd93a788dcd387409299ee7498.tar.gz
sf-9ad19594dfc9eadd93a788dcd387409299ee7498.zip
Implement remove file or directory
Diffstat (limited to 'src')
-rw-r--r--src/fm.c17
-rw-r--r--src/fm.h1
2 files changed, 18 insertions, 0 deletions
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 */