summaryrefslogtreecommitdiffstats
path: root/sm.c
diff options
context:
space:
mode:
authorErik K <erikk@previousplan.org>2022-05-24 09:36:31 +0000
committerErik K <erikk@previousplan.org>2022-05-24 09:36:31 +0000
commit9643e3cb444ee26088be4636ba2b753ac0166156 (patch)
treef8b95c170fc3f368dcd7012626de94f91a5e9342 /sm.c
parentba923d8016ba75fa59d039bc5518e4460d515c40 (diff)
added touch command
Diffstat (limited to 'sm.c')
-rw-r--r--sm.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sm.c b/sm.c
index 3ab7726..59e286e 100644
--- a/sm.c
+++ b/sm.c
@@ -380,6 +380,19 @@ list(const char *filename)
}
static int
+touch(const char *filename)
+{
+ Document *d;
+
+ if ((d = dbfind(filename)) == NULL) {
+ fprintf(stderr, "%s: no such file\n", filename);
+ return 0;
+ }
+ d->creat = d->mod = time(NULL);
+ return 1;
+}
+
+static int
unset(const char *filename, const char *plname)
{
Document *d;
@@ -469,6 +482,9 @@ editcmd:
} else if (!strcmp(cmd.argv[0], "rm")) {
if (dbdel(cmd.argv[1]))
dbwrite(kdbloc);
+ } else if (!strcmp(cmd.argv[0], "touch")) {
+ if (touch(cmd.argv[1]))
+ dbwrite(kdbloc);
} else if (cmd.argc < 3) {
fprintf(stderr, "invalid command/needs more parameters\n");
} else if (!strcmp(cmd.argv[0], "set")) {