diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-11-01 05:09:02 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-11-01 05:11:48 +0300 |
commit | a0633e2484f21c9f80842c10b46b3af98b54d25a (patch) | |
tree | b19b840f0eb683a9cb371cc5b1f275056db05a03 /source/blender/blenkernel/intern/appdir.c | |
parent | d4d38e8a34e59c8762034073b084ed3c5ee09af8 (diff) |
Fix crash when "HOME" environment variable isn't defined
Accessing the default directory in the file selector
would crash if HOME was undefined.
Add BKE_appdir_folder_default_or_root which never returns NULL.
Diffstat (limited to 'source/blender/blenkernel/intern/appdir.c')
-rw-r--r-- | source/blender/blenkernel/intern/appdir.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index ce4ab8a4ba1..08a3b7d0bbb 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -170,6 +170,26 @@ const char *BKE_appdir_folder_default(void) #endif /* WIN32 */ } +const char *BKE_appdir_folder_root(void) +{ +#ifndef WIN32 + return "/"; +#else + static char root[4]; + BLI_windows_get_default_root_dir(root); + return root; +#endif +} + +const char *BKE_appdir_folder_default_or_root(void) +{ + const char *path = BKE_appdir_folder_default(); + if (path == NULL) { + path = BKE_appdir_folder_root(); + } + return path; +} + /** * Get the user's home directory, i.e. * - Unix: `$HOME` |