Fix path canonicalization when $HOME has a trailing slash

master
Andrew Kelley 2019-04-26 14:37:26 -04:00
parent 9ec4ccc68f
commit 1d95fdaf6e
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
1 changed files with 8 additions and 2 deletions

View File

@ -1747,8 +1747,14 @@ Error os_get_app_data_dir(Buf *out_path, const char *appname) {
// TODO use /etc/passwd
return ErrorFileNotFound;
}
buf_resize(out_path, 0);
buf_appendf(out_path, "%s/.local/share/%s", home_dir, appname);
if (home_dir[0] == 0) {
return ErrorFileNotFound;
}
buf_init_from_str(out_path, home_dir);
if (buf_ptr(out_path)[buf_len(out_path) - 1] != '/') {
buf_append_char(out_path, '/');
}
buf_appendf(out_path, ".local/share/%s", appname);
return ErrorNone;
#endif
}