Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/storage.c
| Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * Copies the current working directory into *dir (max size maxncpy), and | * Copies the current working directory into *dir (max size maxncpy), and | ||||
| * returns a pointer to same. | * returns a pointer to same. | ||||
| * | * | ||||
| * \note can return NULL when the size is not big enough | * \note can return NULL when the size is not big enough | ||||
| */ | */ | ||||
| char *BLI_current_working_dir(char *dir, const size_t maxncpy) | char *BLI_current_working_dir(char *dir, const size_t maxncpy) | ||||
| { | { | ||||
| const char *pwd = getenv("PWD"); | const char *pwd = BLI_getenv("PWD"); | ||||
| if (pwd) { | if (pwd) { | ||||
| size_t srclen = BLI_strnlen(pwd, maxncpy); | size_t srclen = BLI_strnlen(pwd, maxncpy); | ||||
| if (srclen != maxncpy) { | if (srclen != maxncpy) { | ||||
| memcpy(dir, pwd, srclen + 1); | memcpy(dir, pwd, srclen + 1); | ||||
| return dir; | return dir; | ||||
| } | } | ||||
| else { | else { | ||||
| return NULL; | return NULL; | ||||
| ▲ Show 20 Lines • Show All 338 Lines • Show Last 20 Lines | |||||