Blender V2.61 - r43446

GHOST_SystemPathsCarbon.cpp

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) 2009 Blender Foundation.
00019  * All rights reserved.
00020  *
00021  * 
00022  * Contributor(s): Damien Plisson 2010
00023  *
00024  * ***** END GPL LICENSE BLOCK *****
00025  */
00026 
00032 #include <Carbon/Carbon.h>
00033 #include <ApplicationServices/ApplicationServices.h>
00034 #include "GHOST_SystemPathsCarbon.h"
00035 
00036 
00037 /***/
00038 
00039 GHOST_SystemPathsCarbon::GHOST_SystemPathsCarbon() 
00040 {
00041 }
00042 
00043 GHOST_SystemPathsCarbon::~GHOST_SystemPathsCarbon()
00044 {
00045 }
00046 
00047 const GHOST_TUns8* GHOST_SystemPathsCarbon::getSystemDir() const
00048 {
00049     return (GHOST_TUns8*)"/Library/Application Support";
00050 }
00051 
00052 const GHOST_TUns8* GHOST_SystemPathsCarbon::getUserDir() const
00053 {
00054     static char usrPath[256] = "";
00055     char* env = getenv("HOME");
00056     
00057     if (env) {
00058         strncpy(usrPath, env, 245);
00059         usrPath[245]=0;
00060         strcat(usrPath, "/Library/Application Support");
00061         return (GHOST_TUns8*) usrPath;
00062     }
00063     else
00064         return NULL;
00065 }
00066 
00067 const GHOST_TUns8* GHOST_SystemPathsCarbon::getBinaryDir() const
00068 {
00069     CFURLRef bundleURL;
00070     CFStringRef pathStr;
00071     static char path[256];
00072     CFBundleRef mainBundle = CFBundleGetMainBundle();
00073     
00074     bundleURL = CFBundleCopyBundleURL(mainBundle);
00075     pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
00076     CFStringGetCString(pathStr, path, 255, kCFStringEncodingASCII);
00077     CFRelease(pathStr);
00078     CFRelease(bundleURL);
00079     return (GHOST_TUns8*)path;
00080 }
00081 
00082 void GHOST_SystemPathsCarbon::addToSystemRecentFiles(const char* filename) const
00083 {
00084     /* XXXXX TODO: Implementation for Carbon if possible */
00085 
00086 }