mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 00:38:17 +00:00
stdpaths: Give proper error message in case directory creation failed
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user