Blender  V2.59
GHOST_SystemPathsCarbon.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: GHOST_SystemPathsCarbon.cpp 35152 2011-02-25 11:28:33Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version. 
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2009 Blender Foundation.
00021  * All rights reserved.
00022  *
00023  * 
00024  * Contributor(s): Damien Plisson 2010
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00034 #include <Carbon/Carbon.h>
00035 #include <ApplicationServices/ApplicationServices.h>
00036 #include "GHOST_SystemPathsCarbon.h"
00037 
00038 
00039 /***/
00040 
00041 GHOST_SystemPathsCarbon::GHOST_SystemPathsCarbon() 
00042 {
00043 }
00044 
00045 GHOST_SystemPathsCarbon::~GHOST_SystemPathsCarbon()
00046 {
00047 }
00048 
00049 const GHOST_TUns8* GHOST_SystemPathsCarbon::getSystemDir() const
00050 {
00051         return (GHOST_TUns8*)"/Library/Application Support";
00052 }
00053 
00054 const GHOST_TUns8* GHOST_SystemPathsCarbon::getUserDir() const
00055 {
00056         static char usrPath[256] = "";
00057         char* env = getenv("HOME");
00058         
00059         if (env) {
00060                 strncpy(usrPath, env, 245);
00061                 usrPath[245]=0;
00062                 strcat(usrPath, "/Library/Application Support");
00063                 return (GHOST_TUns8*) usrPath;
00064         }
00065         else
00066                 return NULL;
00067 }
00068 
00069 const GHOST_TUns8* GHOST_SystemPathsCarbon::getBinaryDir() const
00070 {
00071         CFURLRef bundleURL;
00072         CFStringRef pathStr;
00073         static char path[256];
00074         CFBundleRef mainBundle = CFBundleGetMainBundle();
00075         
00076         bundleURL = CFBundleCopyBundleURL(mainBundle);
00077         pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
00078         CFStringGetCString(pathStr, path, 255, kCFStringEncodingASCII);
00079         CFRelease(pathStr);
00080         CFRelease(bundleURL);
00081         return (GHOST_TUns8*)path;
00082 }
00083 
00084 void GHOST_SystemPathsCarbon::addToSystemRecentFiles(const char* filename) const
00085 {
00086         /* XXXXX TODO: Implementation for Carbon if possible */
00087 
00088 }