Hi, I'm trying to find a place to store a file that should be read/write accessible to my non-sandboxed MacOS app across multiple user accounts. That place was/is supposedly /Library/Application Support/com.whatever.myapp/ (i.e. NOT the user-specific Application Support directory), but my app doesn't seem to have write permission to create a folder/file there. There's a super convoluted way to make a separate process that has elevated privileges just to write a stupid file to there, but surely there's a better way that I'm missing. Is there another location I should be using for this purpose? Or a simpler way to gain write access to that location (simpler than creating a whole separate application to launch as a sub-process with elevated privileges)? There's the old Users/Shared folder, but that seems to be some kind of legacy folder (there aren't current APIs to get its path reliably). I need to be able to write an actual file at a path with normal cross-platform C++ file-writing functions, so I can't use the built-in MacOS user preferences stuff. Here are the two methods I've used to try to create my folder (I'm not actually hard-coding these paths, I'm using the APIs to get the proper root folder name):
// method 1
system("mkdir /Library/Application Support/com.whatever.myapp");
//method 2
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString* directoryNameNS = [NSString stringWithUTF8String:("/Library/Application Support/com.whatever.myapp")];
NSError* error = nil;
bool worked = [fileManager createDirectoryAtPath:directoryNameNS withIntermediateDirectories:YES attributes:nil error:&error];