FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
SystemHelpersMac.mm
1 /**********************************************************\
2 Original Author: Richard Bateman (taxilian)
3 
4 Created: Sep 27, 2011
5 License: Dual license model; choose one of two:
6  New BSD License
7  http://www.opensource.org/licenses/bsd-license.php
8  - or -
9  GNU Lesser General Public License, version 2.1
10  http://www.gnu.org/licenses/lgpl-2.1.html
11 
12 Copyright 2011 GradeCam, Inc and the Firebreath development team
13 \**********************************************************/
14 
15 #include "../SystemHelpers.h"
16 #import <Foundation/NSPathUtilities.h>
17 #import <Foundation/NSAutoreleasePool.h>
18 #import <Foundation/NSFileManager.h>
19 
20 using std::string;
21 
22 string FB::System::getHomeDirPath()
23 {
24  NSAutoreleasePool * pool = [NSAutoreleasePool new];
25  NSString* dir = NSHomeDirectory();
26  string path([dir UTF8String]);
27  [pool release];
28  return path;
29 }
30 
31 string FB::System::getAppDataPath(const string& appName)
32 {
33  NSAutoreleasePool * pool = [NSAutoreleasePool new];
34  // find the path to ~/Library/Application Support/
35  NSArray* paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
36  NSString* strPath = [paths objectAtIndex:0];
37 
38  NSString* appComponent = [NSString stringWithUTF8String:appName.c_str()];
39 
40  strPath = [strPath stringByAppendingPathComponent:appComponent];
41 
42  string path([strPath UTF8String]);
43  [pool release];
44  return path;
45 }
46 
47 string FB::System::getLocalAppDataPath(const string& appName)
48 {
49  return FB::System::getAppDataPath(appName);
50 }
51 
52 string FB::System::getTempPath()
53 {
54  NSAutoreleasePool * pool = [NSAutoreleasePool new];
55  NSString* dir = NSTemporaryDirectory();
56  string path([dir UTF8String]);
57  [pool release];
58  return path;
59 }
60