Vault
4.1
|
00001 /* 00002 Copyright c1997-2014 Trygve Isaacson. All rights reserved. 00003 This file is part of the Code Vault version 4.1 00004 http://www.bombaydigital.com/ 00005 License: MIT. See LICENSE.md in the Vault top level directory. 00006 */ 00007 00016 #include "vtypes.h" 00017 00018 #include "vstring.h" 00019 #import <Foundation/NSAutoreleasePool.h> 00020 #import <Foundation/NSPathUtilities.h> // for NSHomeDirectory() 00021 00022 // VAutoreleasePool ----------------------------------------------------------- 00023 00024 VAutoreleasePool::VAutoreleasePool() { 00025 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 00026 mPool = pool; 00027 } 00028 00029 void VAutoreleasePool::drain() { 00030 NSAutoreleasePool* pool = static_cast<NSAutoreleasePool*>(mPool); 00031 [pool drain]; 00032 } 00033 00034 VAutoreleasePool::~VAutoreleasePool() { 00035 this->drain(); 00036 mPool = nil; 00037 } 00038 00039 // _V_NSHomeDirectory --------------------------------------------------------- 00040 00041 /* 00042 This function is not declared extern in a header file because it's private for 00043 our platform-specific implementation code. We don't even define it in our 00044 platform headers because we don't want to make them require inclusion of vstring.h. 00045 This is only referenced by the Mac OS X version of VFSNode::_platform_getKnownDirectoryNode(), 00046 so it is manually declared extern there to match this. 00047 */ 00048 extern VString _V_NSHomeDirectory(); 00049 VString _V_NSHomeDirectory() { 00050 NSString* currentUserHomePath = NSHomeDirectory(); // Note: autoreleased. Caller needs an autorelease pool context, e.g. VAutoreleasePool. 00051 VString path((CFStringRef) currentUserHomePath); 00052 return path; 00053 }