diff --git a/bin/timesheet b/bin/timesheet index 24cbc22..6d07763 100755 --- a/bin/timesheet +++ b/bin/timesheet @@ -19,7 +19,9 @@ def read_entries(path): return entries def write_entries(path, entries): - os.makedirs(os.path.dirname(path), exist_ok=True) + d = os.path.dirname(path) + if d: + os.makedirs(d, exist_ok=True) with open(path, "w") as f: for e in entries: f.write("\t".join(e) + "\n") diff --git a/src/loadhist.c b/src/loadhist.c index a5800e5..ddf030c 100644 --- a/src/loadhist.c +++ b/src/loadhist.c @@ -20,7 +20,7 @@ static void defpath(char*buf,size_t n){const char*h=getenv("HOME"); if(h)snprintf(buf,n,"%s/.cache/fileutils/loadhist.log",h); else snprintf(buf,n,"/tmp/loadhist.log");} static void ensure_dir(const char*path){char d[1024]; snprintf(d,sizeof d,"%s",path); - char*s=strrchr(d,'/'); if(s)*s=0; char cmd[1100]; snprintf(cmd,sizeof cmd,"mkdir -p '%s'",d); (void)!system(cmd);} + char*s=strrchr(d,'/'); if(!s)return; *s=0; char cmd[1100]; snprintf(cmd,sizeof cmd,"mkdir -p '%s'",d); (void)!system(cmd);} static int show(const char*path,int n){ FILE*f=fopen(path,"r"); if(!f){printf("loadhist: no history yet at %s (run --record first)\n",path); return 0;} double *v=NULL; size_t cnt=0,cap=0; time_t *t=NULL; char line[256];