From d613674a1cfbc9ec801d57f4b8c107b230840d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 29 Mar 2019 19:56:21 +0100 Subject: Cal name now set to basename of path. --- src/calendar.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') 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 #include +/* basename */ +#include + #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; -- cgit v1.2.3