Blender V2.61 - r43446

GHOST_SystemPathsCocoa.mm

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version. 
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2010 Blender Foundation.
00019  * All rights reserved.
00020  *
00021  * 
00022  * Contributor(s): Damien Plisson 2010
00023  *
00024  * ***** END GPL LICENSE BLOCK *****
00025  */
00026 
00027 #import <Cocoa/Cocoa.h>
00028 
00029 /*For the currently not ported to Cocoa keyboard layout functions (64bit & 10.6 compatible)*/
00030 #include <Carbon/Carbon.h>
00031 
00032 #include <sys/time.h>
00033 #include <sys/types.h>
00034 #include <sys/sysctl.h>
00035 
00036 #include "GHOST_SystemPathsCocoa.h"
00037 
00038 
00039 #pragma mark initialization/finalization
00040 
00041 
00042 GHOST_SystemPathsCocoa::GHOST_SystemPathsCocoa()
00043 {
00044 }
00045 
00046 GHOST_SystemPathsCocoa::~GHOST_SystemPathsCocoa()
00047 {
00048 }
00049 
00050 
00051 #pragma mark Base directories retrieval
00052 
00053 const GHOST_TUns8* GHOST_SystemPathsCocoa::getSystemDir() const
00054 {
00055     static GHOST_TUns8 tempPath[512] = "";
00056     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
00057     NSString *basePath;
00058     NSArray *paths;
00059     
00060     paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSLocalDomainMask, YES);
00061     
00062     if ([paths count] > 0)
00063         basePath = [paths objectAtIndex:0];
00064     else { 
00065         [pool drain];
00066         return NULL;
00067     }
00068     
00069     strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
00070     
00071     [pool drain];
00072     return tempPath;
00073 }
00074 
00075 const GHOST_TUns8* GHOST_SystemPathsCocoa::getUserDir() const
00076 {
00077     static GHOST_TUns8 tempPath[512] = "";
00078     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
00079     NSString *basePath;
00080     NSArray *paths;
00081 
00082     paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
00083 
00084     if ([paths count] > 0)
00085         basePath = [paths objectAtIndex:0];
00086     else { 
00087         [pool drain];
00088         return NULL;
00089     }
00090 
00091     strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
00092     
00093     [pool drain];
00094     return tempPath;
00095 }
00096 
00097 const GHOST_TUns8* GHOST_SystemPathsCocoa::getBinaryDir() const
00098 {
00099     static GHOST_TUns8 tempPath[512] = "";
00100     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
00101     NSString *basePath;
00102     
00103     basePath = [[NSBundle mainBundle] bundlePath];
00104     
00105     if (basePath == nil) {
00106         [pool drain];
00107         return NULL;
00108     }
00109     
00110     strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
00111     
00112     [pool drain];
00113     return tempPath;
00114 }
00115 
00116 void GHOST_SystemPathsCocoa::addToSystemRecentFiles(const char* filename) const
00117 {
00118     /* XXXXX TODO: Implementation for X11 if possible */
00119 }