diff options
author | Signal Linden <signal@lindenlab.com> | 2023-04-10 10:54:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-10 10:54:13 -0700 |
commit | 53d4e69c514374622afb93f81067aaeec64a443b (patch) | |
tree | a327a68d2f1f351275539d65fc7237cbdc29c577 /indra/llfilesystem/lldir_utils_objc.mm | |
parent | 4042ed9701fcfa42c03fc285a757aa348f800e33 (diff) | |
parent | ff0edab69a1dc4884b7636c2546327901ce8fdde (diff) |
Merge pull request #159 from secondlife/marchcat/main-contrib-merge
merge main into contribute
Diffstat (limited to 'indra/llfilesystem/lldir_utils_objc.mm')
-rw-r--r-- | indra/llfilesystem/lldir_utils_objc.mm | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/indra/llfilesystem/lldir_utils_objc.mm b/indra/llfilesystem/lldir_utils_objc.mm index da55a2f897..20540fb93c 100644 --- a/indra/llfilesystem/lldir_utils_objc.mm +++ b/indra/llfilesystem/lldir_utils_objc.mm @@ -30,75 +30,75 @@ #include "lldir_utils_objc.h" #import <Cocoa/Cocoa.h> -std::string* getSystemTempFolder() +std::string getSystemTempFolder() { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSString * tempDir = NSTemporaryDirectory(); - if (tempDir == nil) - tempDir = @"/tmp"; - std::string *result = ( new std::string([tempDir UTF8String]) ); - [pool release]; + std::string result; + @autoreleasepool { + NSString * tempDir = NSTemporaryDirectory(); + if (tempDir == nil) + tempDir = @"/tmp"; + result = std::string([tempDir UTF8String]); + } return result; } //findSystemDirectory scoped exclusively to this file. -std::string* findSystemDirectory(NSSearchPathDirectory searchPathDirectory, +std::string findSystemDirectory(NSSearchPathDirectory searchPathDirectory, NSSearchPathDomainMask domainMask) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - std::string *result = nil; - NSString *path = nil; - - // Search for the path - NSArray* paths = NSSearchPathForDirectoriesInDomains(searchPathDirectory, - domainMask, - YES); - if ([paths count]) - { - path = [paths objectAtIndex:0]; - //HACK: Always attempt to create directory, ignore errors. - NSError *error = nil; - - [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error]; - + std::string result; + @autoreleasepool { + NSString *path = nil; - result = new std::string([path UTF8String]); + // Search for the path + NSArray* paths = NSSearchPathForDirectoriesInDomains(searchPathDirectory, + domainMask, + YES); + if ([paths count]) + { + path = [paths objectAtIndex:0]; + //HACK: Always attempt to create directory, ignore errors. + NSError *error = nil; + + [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error]; + + + result = std::string([path UTF8String]); + } } - [pool release]; return result; } -std::string* getSystemExecutableFolder() +std::string getSystemExecutableFolder() { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - NSString *bundlePath = [[NSBundle mainBundle] executablePath]; - std::string *result = (new std::string([bundlePath UTF8String])); - [pool release]; + std::string result; + @autoreleasepool { + NSString *bundlePath = [[NSBundle mainBundle] executablePath]; + result = std::string([bundlePath UTF8String]); + } return result; } -std::string* getSystemResourceFolder() +std::string getSystemResourceFolder() { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - NSString *bundlePath = [[NSBundle mainBundle] resourcePath]; - std::string *result = (new std::string([bundlePath UTF8String])); - [pool release]; + std::string result; + @autoreleasepool { + NSString *bundlePath = [[NSBundle mainBundle] resourcePath]; + result = std::string([bundlePath UTF8String]); + } return result; } -std::string* getSystemCacheFolder() +std::string getSystemCacheFolder() { return findSystemDirectory (NSCachesDirectory, NSUserDomainMask); } -std::string* getSystemApplicationSupportFolder() +std::string getSystemApplicationSupportFolder() { return findSystemDirectory (NSApplicationSupportDirectory, NSUserDomainMask); |