diff src/sys/osx/filesystem.cc @ 196:f0ff06a45c42

date: use std::optional for values
author Paper <mrpapersonic@gmail.com>
date Thu, 07 Dec 2023 16:28:11 -0500
parents 975a3f0965e2
children c4ca035c565d
line wrap: on
line diff
--- a/src/sys/osx/filesystem.cc	Thu Dec 07 11:14:01 2023 -0500
+++ b/src/sys/osx/filesystem.cc	Thu Dec 07 16:28:11 2023 -0500
@@ -18,22 +18,26 @@
 namespace osx {
 
 bool GetApplicationSupportDirectory(std::string& result) {
-	const CFArrayRef strings = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, true);
+	// NSArray* strings = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, ON);
+	const CFArrayRef strings = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, ON);
 	if (!strings)
 		return false;
 
+	// NSIndex index = [strings count];
 	const CFIndex count = CFArrayGetCount(strings);
 	if (count < 1) {
 		CFRelease(strings);
 		return false;
 	}
 
+	// NSString* string = [strings objectAtIndex: 0];
 	const CFStringRef string = reinterpret_cast<CFStringRef>(CFArrayGetValueAtIndex(strings, 0));
 	if (!string) {
 		CFRelease(strings);
 		return false;
 	}
 
+	// result = [string UTF8String];
 	result.resize(CFStringGetMaximumSizeForEncoding(CFStringGetLength(string), kCFStringEncodingUTF8) + 1);
 	if (!CFStringGetCString(string, &result.front(), result.length(), kCFStringEncodingUTF8)) {
 		CFRelease(strings);