diff options
author | Ankit Meel <ankitjmeel@gmail.com> | 2021-12-11 19:59:53 +0300 |
---|---|---|
committer | Ankit Meel <ankitjmeel@gmail.com> | 2021-12-11 19:59:53 +0300 |
commit | 9df13fba69c3b0e0e013db198515e6e1a7238f6a (patch) | |
tree | bd885ea12f406316ab38e42465cc864328c45bd2 /source/blender/blenlib/intern/storage_apple.mm | |
parent | 23be5fd4499ad92c049f140564df3e32cfe9cea3 (diff) |
macOS: add tilde-based path expander
Replaces `HOME` environment variable usage for user
directories like in D12802.
Reviewed By: #platform_macos, brecht
Differential Revision: https://developer.blender.org/D13212
Diffstat (limited to 'source/blender/blenlib/intern/storage_apple.mm')
-rw-r--r-- | source/blender/blenlib/intern/storage_apple.mm | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/storage_apple.mm b/source/blender/blenlib/intern/storage_apple.mm index 07091f2b055..b0234b9a093 100644 --- a/source/blender/blenlib/intern/storage_apple.mm +++ b/source/blender/blenlib/intern/storage_apple.mm @@ -184,3 +184,20 @@ 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 { + const NSString *const str_with_tilde = [[NSString alloc] initWithCString:path_with_tilde + encoding:NSUTF8StringEncoding]; + if (!str_with_tilde) { + return nullptr; + } + const NSString *const str_expanded = [str_with_tilde stringByExpandingTildeInPath]; + [str_expanded getCString:path_expanded + maxLength:sizeof(path_expanded) + encoding:NSUTF8StringEncoding]; + } + return path_expanded; +} |