Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_SystemPathsCocoa.mm
| /* | /* | ||||
| * This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
| * modify it under the terms of the GNU General Public License | * modify it under the terms of the GNU General Public License | ||||
| * as published by the Free Software Foundation; either version 2 | * as published by the Free Software Foundation; either version 2 | ||||
| * of the License, or (at your option) any later version. | * of the License, or (at your option) any later version. | ||||
| * | * | ||||
| * This program is distributed in the hope that it will be useful, | * This program is distributed in the hope that it will be useful, | ||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
| * GNU General Public License for more details. | * GNU General Public License for more details. | ||||
| * | * | ||||
| * You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
| * along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| * | * | ||||
| * The Original Code is Copyright (C) 2010 Blender Foundation. | * The Original Code is Copyright (C) 2010 Blender Foundation. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| * | * | ||||
| * | * | ||||
| */ | */ | ||||
| #import <Foundation/Foundation.h> | #import <Foundation/Foundation.h> | ||||
| #include "GHOST_SystemPathsCocoa.h" | #include "GHOST_SystemPathsCocoa.h" | ||||
| #pragma mark initialization/finalization | #pragma mark initialization/finalization | ||||
| Show All 11 Lines | |||||
| #pragma mark Base directories retrieval | #pragma mark Base directories retrieval | ||||
| const GHOST_TUns8* GHOST_SystemPathsCocoa::getSystemDir(int, const char *versionstr) const | const GHOST_TUns8* GHOST_SystemPathsCocoa::getSystemDir(int, const char *versionstr) const | ||||
| { | { | ||||
| static char tempPath[512] = ""; | static char tempPath[512] = ""; | ||||
| NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | ||||
| NSString *basePath; | NSString *basePath; | ||||
| NSArray *paths; | NSArray *paths; | ||||
| paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSLocalDomainMask, YES); | paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSLocalDomainMask, YES); | ||||
| if ([paths count] > 0) | if ([paths count] > 0) | ||||
| basePath = [paths objectAtIndex:0]; | basePath = [paths objectAtIndex:0]; | ||||
| else { | else { | ||||
| [pool drain]; | [pool drain]; | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| snprintf(tempPath, sizeof(tempPath), "%s/Blender/%s", [basePath cStringUsingEncoding:NSASCIIStringEncoding], versionstr); | snprintf(tempPath, sizeof(tempPath), "%s/Blender/%s", [basePath cStringUsingEncoding:NSASCIIStringEncoding], versionstr); | ||||
| [pool drain]; | [pool drain]; | ||||
| return (GHOST_TUns8*)tempPath; | return (GHOST_TUns8*)tempPath; | ||||
| } | } | ||||
| const GHOST_TUns8* GHOST_SystemPathsCocoa::getUserDir(int, const char *versionstr) const | const GHOST_TUns8* GHOST_SystemPathsCocoa::getUserDir(int, const char *versionstr) const | ||||
| { | { | ||||
| static char tempPath[512] = ""; | static char tempPath[512] = ""; | ||||
| NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | ||||
| NSString *basePath; | NSString *basePath; | ||||
| NSArray *paths; | NSArray *paths; | ||||
| paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); | paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); | ||||
| if ([paths count] > 0) | if ([paths count] > 0) | ||||
| basePath = [paths objectAtIndex:0]; | basePath = [paths objectAtIndex:0]; | ||||
| else { | else { | ||||
| [pool drain]; | [pool drain]; | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| snprintf(tempPath, sizeof(tempPath), "%s/Blender/%s", [basePath cStringUsingEncoding:NSASCIIStringEncoding], versionstr); | snprintf(tempPath, sizeof(tempPath), "%s/Blender/%s", [basePath cStringUsingEncoding:NSASCIIStringEncoding], versionstr); | ||||
| [pool drain]; | [pool drain]; | ||||
| return (GHOST_TUns8*)tempPath; | return (GHOST_TUns8*)tempPath; | ||||
| } | } | ||||
| const GHOST_TUns8* GHOST_SystemPathsCocoa::getBinaryDir() const | const GHOST_TUns8* GHOST_SystemPathsCocoa::getBinaryDir() const | ||||
| { | { | ||||
| static GHOST_TUns8 tempPath[512] = ""; | static GHOST_TUns8 tempPath[512] = ""; | ||||
| NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | ||||
| NSString *basePath; | NSString *basePath; | ||||
| basePath = [[NSBundle mainBundle] bundlePath]; | basePath = [[NSBundle mainBundle] bundlePath]; | ||||
| if (basePath == nil) { | if (basePath == nil) { | ||||
| [pool drain]; | [pool drain]; | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]); | strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]); | ||||
| [pool drain]; | [pool drain]; | ||||
| return tempPath; | return tempPath; | ||||
| } | } | ||||
| void GHOST_SystemPathsCocoa::addToSystemRecentFiles(const char* filename) const | void GHOST_SystemPathsCocoa::addToSystemRecentFiles(const char* filename) const | ||||
| { | { | ||||
| /* XXXXX TODO: Implementation for X11 if possible */ | /* XXXXX TODO: Implementation for X11 if possible */ | ||||
| } | } | ||||