diff --git a/source/blender/blenkernel/intern/appdir.cc b/source/blender/blenkernel/intern/appdir.cc index 4d7a15e72b3..179b1f61210 100644 --- a/source/blender/blenkernel/intern/appdir.cc +++ b/source/blender/blenkernel/intern/appdir.cc @@ -231,8 +231,8 @@ bool BKE_appdir_font_folder_default(char *dir, size_t dir_maxncpy) BLI_strncpy_wchar_as_utf8(test_dir, wpath, sizeof(test_dir)); } #elif defined(__APPLE__) - if (const char *fonts_dir = BLI_expand_tilde("~/Library/Fonts")) { - STRNCPY(test_dir, fonts_dir); + if (const char *home_dir = BLI_dir_home()) { + BLI_path_join(test_dir, sizeof(test_dir), home_dir, "Library/Fonts"); } #else STRNCPY(test_dir, "/usr/share/fonts"); diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index c50c3de1e92..cb566bcd67c 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -440,14 +440,6 @@ void *BLI_file_read_binary_as_mem(const char *filepath, size_t pad_bytes, size_t */ void BLI_file_free_lines(struct LinkNode *lines); -#ifdef __APPLE__ -/** - * Expand the leading `~` in the given path to `/Users/$USER`. - * This doesn't preserve the trailing path separator. - * Giving a path without leading `~` is not an error. - */ -const char *BLI_expand_tilde(const char *path_with_tilde); -#endif /* This weirdo pops up in two places. */ #if !defined(WIN32) # ifndef O_BINARY diff --git a/source/blender/blenlib/intern/storage.cc b/source/blender/blenlib/intern/storage.cc index 8c28b5c0a3b..09abbccf98c 100644 --- a/source/blender/blenlib/intern/storage.cc +++ b/source/blender/blenlib/intern/storage.cc @@ -109,21 +109,15 @@ char *BLI_current_working_dir(char *dir, const size_t maxncpy) const char *BLI_dir_home() { - const char *home_dir = nullptr; + const char *home_dir; #ifdef WIN32 home_dir = BLI_getenv("userprofile"); #else - -# if defined(__APPLE__) - home_dir = BLI_expand_tilde("~/"); -# endif + home_dir = BLI_getenv("HOME"); if (home_dir == nullptr) { - home_dir = BLI_getenv("HOME"); - if (home_dir == nullptr) { - if (const passwd *pwuser = getpwuid(getuid())) { - home_dir = pwuser->pw_dir; - } + if (const passwd *pwuser = getpwuid(getuid())) { + home_dir = pwuser->pw_dir; } } #endif diff --git a/source/blender/blenlib/intern/storage_apple.mm b/source/blender/blenlib/intern/storage_apple.mm index 3c9d917909d..9feabb776f0 100644 --- a/source/blender/blenlib/intern/storage_apple.mm +++ b/source/blender/blenlib/intern/storage_apple.mm @@ -175,23 +175,6 @@ eFileAttributes BLI_file_attributes(const char *path) return (eFileAttributes)ret; } -const char *BLI_expand_tilde(const char *path_with_tilde) -{ - static char path_expanded[FILE_MAX]; - @autoreleasepool { - NSString *str_with_tilde = [[NSString alloc] initWithCString:path_with_tilde - encoding:NSUTF8StringEncoding]; - if (!str_with_tilde) { - return nullptr; - } - NSString *str_expanded = [str_with_tilde stringByExpandingTildeInPath]; - [str_expanded getCString:path_expanded - maxLength:sizeof(path_expanded) - encoding:NSUTF8StringEncoding]; - } - return path_expanded; -} - char *BLI_current_working_dir(char *dir, const size_t maxncpy) { /* Can't just copy to the *dir pointer, as [path getCString gets grumpy. */