Mercurial > minori
comparison src/sys/osx/filesystem.cc @ 195:975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
also the general application stuff and anime list is separated in settings
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Thu, 07 Dec 2023 11:14:01 -0500 |
| parents | 8548dc425697 |
| children | f0ff06a45c42 |
comparison
equal
deleted
inserted
replaced
| 194:8548dc425697 | 195:975a3f0965e2 |
|---|---|
| 1 #include "sys/osx/filesystem.h" | 1 #include "sys/osx/filesystem.h" |
| 2 | 2 |
| 3 #include <CoreFoundation/CoreFoundation.h> | 3 #include <CoreFoundation/CoreFoundation.h> |
| 4 #include <objc/runtime.h> | |
| 4 | 5 |
| 5 #include <string> | 6 #include <string> |
| 6 | 7 |
| 8 /* These constants are defined in Foundation but not | |
| 9 * exposed to CoreFoundation users. | |
| 10 */ | |
| 7 static constexpr unsigned long NSApplicationSupportDirectory = 14; | 11 static constexpr unsigned long NSApplicationSupportDirectory = 14; |
| 8 static constexpr unsigned long NSUserDomainMask = 1; | 12 static constexpr unsigned long NSUserDomainMask = 1; |
| 9 | 13 |
| 10 extern "C" { | 14 extern "C" { |
| 11 CFArrayRef NSSearchPathForDirectoriesInDomains(unsigned long directory, unsigned long domainMask, int expandTilde); | 15 CFArrayRef NSSearchPathForDirectoriesInDomains(unsigned long directory, unsigned long domainMask, BOOL expandTilde); |
| 12 } | 16 } |
| 13 | 17 |
| 14 namespace osx { | 18 namespace osx { |
| 15 | 19 |
| 16 bool GetApplicationSupportDirectory(std::string& result) { | 20 bool GetApplicationSupportDirectory(std::string& result) { |
| 33 result.resize(CFStringGetMaximumSizeForEncoding(CFStringGetLength(string), kCFStringEncodingUTF8) + 1); | 37 result.resize(CFStringGetMaximumSizeForEncoding(CFStringGetLength(string), kCFStringEncodingUTF8) + 1); |
| 34 if (!CFStringGetCString(string, &result.front(), result.length(), kCFStringEncodingUTF8)) { | 38 if (!CFStringGetCString(string, &result.front(), result.length(), kCFStringEncodingUTF8)) { |
| 35 CFRelease(strings); | 39 CFRelease(strings); |
| 36 return false; | 40 return false; |
| 37 } | 41 } |
| 38 result.resize(result.find('\0')); | 42 result.resize(result.find_first_of('\0')); |
| 39 | 43 |
| 40 return true; | 44 return true; |
| 41 } | 45 } |
| 42 | 46 |
| 43 } // namespace osx | 47 } // namespace osx |
