diff options
author | Erik K <erikk@previousplan.org> | 2022-05-24 09:36:31 +0000 |
---|---|---|
committer | Erik K <erikk@previousplan.org> | 2022-05-24 09:36:31 +0000 |
commit | 9643e3cb444ee26088be4636ba2b753ac0166156 (patch) | |
tree | f8b95c170fc3f368dcd7012626de94f91a5e9342 /sm.c | |
parent | ba923d8016ba75fa59d039bc5518e4460d515c40 (diff) |
added touch command
Diffstat (limited to 'sm.c')
-rw-r--r-- | sm.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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")) { |