Core: replace home environment variable access with BLI_dir_home

Also check null check the value.
This commit is contained in:
Campbell Barton
2024-10-09 15:42:15 +11:00
parent 7dc92ab0d1
commit 6c4d699268
4 changed files with 23 additions and 6 deletions

View File

@@ -38,6 +38,10 @@
# include <tbb/spin_mutex.h>
# endif
# ifdef _WIN_32
# include "BLI_fileops.h"
# endif
// # define PERFDEBUG
namespace blender::meshintersect {
@@ -627,7 +631,11 @@ static void write_obj_cell_patch(const IMesh &m,
* This is just for developer debugging anyway,
* and should never be called in production Blender. */
# ifdef _WIN_32
const char *objdir = BLI_getenv("HOME");
const char *objdir = BLI_dir_home();
if (objdir == nullptr) {
std::cout << "Could not access home directory\n";
return;
}
# else
const char *objdir = "/tmp/";
# endif

View File

@@ -42,6 +42,10 @@
// # define PERFDEBUG
# ifdef _WIN_32
# include "BLI_fileops.h"
# endif
namespace blender::meshintersect {
# ifdef PERFDEBUG
@@ -3105,10 +3109,15 @@ void write_obj_mesh(IMesh &m, const std::string &objname)
* This is just for developer debugging anyway,
* and should never be called in production Blender. */
# ifdef _WIN_32
const char *objdir = BLI_getenv("HOME");
const char *objdir = BLI_dir_home();
if (objdir == nullptr) {
std::cout << "Could not access home directory\n";
return;
}
# else
const char *objdir = "/tmp/";
# endif
if (m.face_size() == 0) {
return;
}

View File

@@ -398,7 +398,7 @@ void fsmenu_read_system(FSMenu *fsmenu, int read_bookmarks)
ICON_FILE_FOLDER,
FS_INSERT_LAST);
const char *home = BLI_getenv("HOME");
const char *home = BLI_dir_home();
if (home) {
# define FS_MACOS_PATH(path, name, icon) \
\
@@ -538,7 +538,7 @@ void fsmenu_read_system(FSMenu *fsmenu, int read_bookmarks)
#else
/* unix */
{
const char *home = BLI_getenv("HOME");
const char *home = BLI_dir_home();
if (read_bookmarks && home) {

View File

@@ -81,9 +81,9 @@ static bool get_thumb_dir(char *dir, ThumbSize size)
#else
# if defined(USE_FREEDESKTOP)
const char *home_cache = BLI_getenv("XDG_CACHE_HOME");
const char *home = home_cache ? home_cache : BLI_getenv("HOME");
const char *home = home_cache ? home_cache : BLI_dir_home();
# else
const char *home = BLI_getenv("HOME");
const char *home = BLI_dir_home();
# endif
if (!home) {
return false;