stdpaths: Give proper error message in case directory creation failed

This commit is contained in:
ZyX
2015-10-17 15:48:38 +03:00
parent 2e750973e9
commit a06a8bad60

View File

@@ -64,13 +64,15 @@ static char *get_xdg_home(const XDGVarType idx)
return dir; return dir;
} }
static void create_dir(const char *dir, int mode, const char *suffix) static void create_dir(const char *dir, int mode)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
char *failed; char *failed;
if (!os_mkdir_recurse(dir, mode, &failed)) { int err;
// TODO: Create a folder in $TMPDIR instead if ((err = os_mkdir_recurse(dir, mode, &failed)) != 0) {
DLOG("Create dir failed"); EMSG3(_("E920: Failed to create data directory %s: %s"), failed,
os_strerror(-err));
xfree(failed);
} }
} }
@@ -85,7 +87,7 @@ char *stdpaths_user_data_subpath(const char *fname)
{ {
char *dir = concat_fnames_realloc(get_xdg_home(kXDGDataHome), fname, true); char *dir = concat_fnames_realloc(get_xdg_home(kXDGDataHome), fname, true);
if (!os_isdir((char_u *)dir)) { if (!os_isdir((char_u *)dir)) {
create_dir(dir, 0755, fname); create_dir(dir, 0755);
} }
return dir; return dir;
} }