diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-29 19:56:21 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-29 19:56:21 +0100 |
commit | d613674a1cfbc9ec801d57f4b8c107b230840d9c (patch) | |
tree | f5b8dfe88ad660e22c99a96471316e470401bb08 /src | |
parent | Minor whitespace fixup. (diff) | |
download | calp-d613674a1cfbc9ec801d57f4b8c107b230840d9c.tar.gz calp-d613674a1cfbc9ec801d57f4b8c107b230840d9c.tar.xz |
Cal name now set to basename of path.
Diffstat (limited to '')
-rw-r--r-- | src/calendar.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/calendar.c b/src/calendar.c index 403ae83c..5ec2b91d 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -6,6 +6,9 @@ #include <stdio.h> #include <errno.h> +/* basename */ +#include <libgen.h> + #include "parse.h" #include "err.h" @@ -38,7 +41,8 @@ int read_vcalendar(vcomponent* cal, char* path) { int handle_file(vcomponent* cal, char* path) { INFO("Parsing a single file"); - vcomponent_push_val(cal, "NAME", path); + /* NAME is the `fancy' name of the calendar. */ + vcomponent_push_val(cal, "NAME", basename(path)); vcomponent_push_val(cal, "X-HNH-SOURCETYPE", "file"); char* resolved_path = realpath(path, NULL); open_ics (resolved_path, cal); @@ -61,11 +65,8 @@ int handle_dir(vcomponent* cal, char* path) { buf[path_len - 1] = '/'; - /* - * NAME is the `fancy' name of the calendar. - * TODO cut path to its last component. - */ - vcomponent_push_val(cal, "NAME", path); + /* NAME is the `fancy' name of the calendar. */ + vcomponent_push_val(cal, "NAME", basename(path)); vcomponent_push_val(cal, "X-HNH-SOURCETYPE", "vdir"); struct dirent* d; |