mirror of
https://github.com/neovim/neovim.git
synced 2025-09-15 15:58:17 +00:00
stdpaths: Do NOT create data directories
This is none of option.c business to create *possibly unneeded* **default** directories **before** user specified where he actually wants to place the files.
This commit is contained in:
@@ -64,18 +64,6 @@ static char *get_xdg_home(const XDGVarType idx)
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_dir(const char *dir, int mode)
|
|
||||||
FUNC_ATTR_NONNULL_ALL
|
|
||||||
{
|
|
||||||
char *failed;
|
|
||||||
int err;
|
|
||||||
if ((err = os_mkdir_recurse(dir, mode, &failed)) != 0) {
|
|
||||||
EMSG3(_("E920: Failed to create data directory %s: %s"), failed,
|
|
||||||
os_strerror(-err));
|
|
||||||
xfree(failed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
char *stdpaths_user_conf_subpath(const char *fname)
|
char *stdpaths_user_conf_subpath(const char *fname)
|
||||||
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
@@ -85,9 +73,5 @@ char *stdpaths_user_conf_subpath(const char *fname)
|
|||||||
char *stdpaths_user_data_subpath(const char *fname)
|
char *stdpaths_user_data_subpath(const char *fname)
|
||||||
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
char *dir = concat_fnames_realloc(get_xdg_home(kXDGDataHome), fname, true);
|
return concat_fnames_realloc(get_xdg_home(kXDGDataHome), fname, true);
|
||||||
if (!os_isdir((char_u *)dir)) {
|
|
||||||
create_dir(dir, 0755);
|
|
||||||
}
|
|
||||||
return dir;
|
|
||||||
}
|
}
|
||||||
|
@@ -364,7 +364,7 @@ static inline char *do_concat_fnames(char *fname1, const size_t len1,
|
|||||||
/// if necessary
|
/// if necessary
|
||||||
/// @return [allocated] Concatenation of fname1 and fname2.
|
/// @return [allocated] Concatenation of fname1 and fname2.
|
||||||
char *concat_fnames(const char *fname1, const char *fname2, bool sep)
|
char *concat_fnames(const char *fname1, const char *fname2, bool sep)
|
||||||
FUNC_ATTR_NONNULL_ARG(1, 2) FUNC_ATTR_NONNULL_RET
|
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
|
||||||
{
|
{
|
||||||
const size_t len1 = strlen(fname1);
|
const size_t len1 = strlen(fname1);
|
||||||
const size_t len2 = strlen(fname2);
|
const size_t len2 = strlen(fname2);
|
||||||
@@ -376,7 +376,8 @@ char *concat_fnames(const char *fname1, const char *fname2, bool sep)
|
|||||||
/// Concatenate file names fname1 and fname2
|
/// Concatenate file names fname1 and fname2
|
||||||
///
|
///
|
||||||
/// Like concat_fnames(), but in place of allocating new memory it reallocates
|
/// Like concat_fnames(), but in place of allocating new memory it reallocates
|
||||||
/// fname1. For this reason fname1 must be allocated with xmalloc.
|
/// fname1. For this reason fname1 must be allocated with xmalloc, and can no
|
||||||
|
/// longer be used after running concat_fnames_realloc.
|
||||||
///
|
///
|
||||||
/// @param fname1 is the first part of the path or filename
|
/// @param fname1 is the first part of the path or filename
|
||||||
/// @param fname2 is the second half of the path or filename
|
/// @param fname2 is the second half of the path or filename
|
||||||
@@ -384,7 +385,7 @@ char *concat_fnames(const char *fname1, const char *fname2, bool sep)
|
|||||||
/// if necessary
|
/// if necessary
|
||||||
/// @return [allocated] Concatenation of fname1 and fname2.
|
/// @return [allocated] Concatenation of fname1 and fname2.
|
||||||
char *concat_fnames_realloc(char *fname1, const char *fname2, bool sep)
|
char *concat_fnames_realloc(char *fname1, const char *fname2, bool sep)
|
||||||
FUNC_ATTR_NONNULL_ARG(1, 2) FUNC_ATTR_NONNULL_RET
|
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
|
||||||
{
|
{
|
||||||
const size_t len1 = strlen(fname1);
|
const size_t len1 = strlen(fname1);
|
||||||
const size_t len2 = strlen(fname2);
|
const size_t len2 = strlen(fname2);
|
||||||
|
Reference in New Issue
Block a user