From acc53a1c226999878d26b0b4bd58ac8df3256c06 Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Tue, 27 Nov 2012 14:27:52 -0800 Subject: New VFS objects included in every bite! --- indra/llvfs/llvfs_objc.mm | 93 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 indra/llvfs/llvfs_objc.mm (limited to 'indra/llvfs/llvfs_objc.mm') diff --git a/indra/llvfs/llvfs_objc.mm b/indra/llvfs/llvfs_objc.mm new file mode 100644 index 0000000000..4d7cd3a93e --- /dev/null +++ b/indra/llvfs/llvfs_objc.mm @@ -0,0 +1,93 @@ +/** + * @file llvfs_objc.cpp + * @brief Cocoa implementation of directory utilities for Mac OS X + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ +#if LL_DARWIN + +//WARNING: This file CANNOT use standard linden includes due to conflicts between definitions of BOOL + +#include "llvfs_objc.h" +#import + +std::string* getSystemTempFolder() +{ + NSString * tempDir = NSTemporaryDirectory(); + if (tempDir == nil) + tempDir = @"/tmp"; + return ( new std::string([tempDir UTF8String]) ); +} + +//findSystemDirectory scoped exclusively to this file. +std::string* findSystemDirectory(NSSearchPathDirectory searchPathDirectory, + NSSearchPathDomainMask domainMask) +{ + std::string *result; + NSString *path = nil; + + // Search for the path + NSArray* paths = NSSearchPathForDirectoriesInDomains(searchPathDirectory, + domainMask, + YES); + if ([paths count]) + { + NSString *bundleName = + [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]; + path = [[paths objectAtIndex:0] stringByAppendingPathComponent:bundleName]; + + //SPATTERS HACK: Always attempt to create directory, ignore errors. + NSError *error = nil; + + [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error]; + + + result = new std::string([path UTF8String]); + } + return result; +} + +std::string* getSystemExecutableFolder() +{ + NSString *bundlePath = [[NSBundle mainBundle] executablePath]; + return (new std::string([bundlePath UTF8String])); +} + +std::string* getSystemResourceFolder() +{ + NSString *bundlePath = [[NSBundle mainBundle] resourcePath]; + return (new std::string([bundlePath UTF8String])); +} + +std::string* getSystemCacheFolder() +{ + return findSystemDirectory (NSCachesDirectory, + NSUserDomainMask); +} + +std::string* getSystemApplicationSupportFolder() +{ + return findSystemDirectory (NSApplicationSupportDirectory, + NSUserDomainMask); +} + +#endif // LL_DARWIN -- cgit v1.2.3 From 53ea30af06f94b5462fada7c4bfea3122b50ff95 Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Tue, 11 Dec 2012 06:56:14 -0800 Subject: Interim debug checkin to test from teamcity --- indra/llvfs/llvfs_objc.mm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/llvfs/llvfs_objc.mm') diff --git a/indra/llvfs/llvfs_objc.mm b/indra/llvfs/llvfs_objc.mm index 4d7cd3a93e..61cfad99d6 100644 --- a/indra/llvfs/llvfs_objc.mm +++ b/indra/llvfs/llvfs_objc.mm @@ -51,10 +51,10 @@ std::string* findSystemDirectory(NSSearchPathDirectory searchPathDirectory, YES); if ([paths count]) { - NSString *bundleName = - [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]; - path = [[paths objectAtIndex:0] stringByAppendingPathComponent:bundleName]; - + //NSString *bundleName = @"SecondLife"; + //[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]; + //path = [[paths objectAtIndex:0] stringByAppendingPathComponent:bundleName]; + path = [paths objectAtIndex:0]; //SPATTERS HACK: Always attempt to create directory, ignore errors. NSError *error = nil; @@ -88,6 +88,7 @@ std::string* getSystemApplicationSupportFolder() { return findSystemDirectory (NSApplicationSupportDirectory, NSUserDomainMask); + } #endif // LL_DARWIN -- cgit v1.2.3 From 6b059d183b9516f45e775bde00f255cef8aab7c0 Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Tue, 11 Dec 2012 07:40:26 -0800 Subject: Crash reporter fixed, debugging removed. --- indra/llvfs/llvfs_objc.mm | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/llvfs/llvfs_objc.mm') diff --git a/indra/llvfs/llvfs_objc.mm b/indra/llvfs/llvfs_objc.mm index 61cfad99d6..16cfefda26 100644 --- a/indra/llvfs/llvfs_objc.mm +++ b/indra/llvfs/llvfs_objc.mm @@ -51,9 +51,6 @@ std::string* findSystemDirectory(NSSearchPathDirectory searchPathDirectory, YES); if ([paths count]) { - //NSString *bundleName = @"SecondLife"; - //[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]; - //path = [[paths objectAtIndex:0] stringByAppendingPathComponent:bundleName]; path = [paths objectAtIndex:0]; //SPATTERS HACK: Always attempt to create directory, ignore errors. NSError *error = nil; -- cgit v1.2.3 From c1db961ab9b7aa9c0dd43cadf850b7527b77e95b Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Sun, 16 Dec 2012 17:45:55 -0800 Subject: Fixed small one-time memory leaks. --- indra/llvfs/llvfs_objc.mm | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'indra/llvfs/llvfs_objc.mm') diff --git a/indra/llvfs/llvfs_objc.mm b/indra/llvfs/llvfs_objc.mm index 16cfefda26..4f9e2f81e9 100644 --- a/indra/llvfs/llvfs_objc.mm +++ b/indra/llvfs/llvfs_objc.mm @@ -32,16 +32,22 @@ std::string* getSystemTempFolder() { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString * tempDir = NSTemporaryDirectory(); if (tempDir == nil) tempDir = @"/tmp"; - return ( new std::string([tempDir UTF8String]) ); + std::string *result = ( new std::string([tempDir UTF8String]) ); + [pool release]; + + return result; } //findSystemDirectory scoped exclusively to this file. std::string* findSystemDirectory(NSSearchPathDirectory searchPathDirectory, NSSearchPathDomainMask domainMask) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + std::string *result; NSString *path = nil; @@ -60,19 +66,30 @@ std::string* findSystemDirectory(NSSearchPathDirectory searchPathDirectory, result = new std::string([path UTF8String]); } + [pool release]; return result; } std::string* getSystemExecutableFolder() { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSString *bundlePath = [[NSBundle mainBundle] executablePath]; - return (new std::string([bundlePath UTF8String])); + std::string *result = (new std::string([bundlePath UTF8String])); + [pool release]; + + return result; } std::string* getSystemResourceFolder() { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSString *bundlePath = [[NSBundle mainBundle] resourcePath]; - return (new std::string([bundlePath UTF8String])); + std::string *result = (new std::string([bundlePath UTF8String])); + [pool release]; + + return result; } std::string* getSystemCacheFolder() -- cgit v1.2.3