Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Weikert <elubie@gmx.net>2010-07-05 01:14:59 +0400
committerAndrea Weikert <elubie@gmx.net>2010-07-05 01:14:59 +0400
commit4135f1310c145d8df5e1195e3205715ada8296cb (patch)
tree5de45bd384aaae717aa16cd8796f0f54f72e0d15 /source/blender
parent83a2a4e5b889a023cb3d22120f348bd9e96bc2bb (diff)
Patch [#22339] File/installation paths changes
Update after discussions on IRC: * operating system specific path retrieval is moved back to GHOST, nothing blender specific here though * cleaned up path functions a bit to remove #ifdefs * removed Cocoa from blenlib again TODO: * Matt, Damien, please check and correct the functions for Cocoa and Carbon, could only put back existing code but needs adjustment * finish GHOST_getBinaryDir - this should replace the BLI_where_am_i eventually as well as BLI_getInstallationPath on Windows and get_install_dir for the blenderplayer runtime * It would probably be nice to define GHOST_getTempDir as well and move those out * more cleanups... NOTE: Things are likely broken for macs
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenlib/BLI_path_util.h5
-rw-r--r--source/blender/blenlib/CMakeLists.txt4
-rw-r--r--source/blender/blenlib/intern/path_util.c71
-rw-r--r--source/blender/blenlib/intern/path_util_cocoa.mm94
4 files changed, 20 insertions, 154 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index e2cb0e131a5..d149f15cd35 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -100,6 +100,11 @@ char *BLI_get_folder_create(int folder_id, char *subfolder);
#define BLENDER_BOOKMARK_FILE "bookmarks.txt"
#define BLENDER_HISTORY_FILE "recent-files.txt"
+#ifdef WIN32
+#define BLENDER_BASE_FORMAT "%s\\Blender Foundation\\Blender\\%s"
+#else
+#define BLENDER_BASE_FORMAT "%s/.blender/%s"
+#endif
void BLI_setenv(const char *env, const char *val);
void BLI_setenv_if_new(const char *env, const char* val);
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 21cd92c0e95..628c2dc43a5 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -33,10 +33,6 @@ SET(INC
${ZLIB_INC}
)
-IF(APPLE)
- SET(SRC ${SRC} intern/path_util_cocoa.mm)
-ENDIF(APPLE)
-
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
SET(INC
${INC}
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index a3c0f994c05..7be8e069bd0 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -46,8 +46,7 @@
#include "BKE_utildefines.h"
#include "BKE_blender.h" // BLENDER_VERSION
-
-
+#include "GHOST_Path-api.h"
#ifdef WIN32
@@ -916,7 +915,7 @@ char *BLI_gethome_folder(char *folder_name, int flag)
/* ************************************************************* */
/* ************************************************************* */
-#define PATH_DEBUG2
+// #define PATH_DEBUG2
static char *blender_version_decimal(void)
{
@@ -1004,54 +1003,20 @@ static int get_path_local(char *targetpath, char *folder_name)
return 0;
}
-#ifdef WIN32
-static int get_knownfolder_path(char *path, int folder)
-{
- static char knownpath[MAXPATHLEN];
- HRESULT hResult = SHGetFolderPath(NULL, folder, NULL, SHGFP_TYPE_CURRENT, knownpath);
-
- if (hResult == S_OK)
- {
- if (BLI_exists(knownpath)) { /* from fop, also below... */
- BLI_strncpy(path, knownpath, FILE_MAX);
- return 1;
- }
- }
- return 0;
-}
-#endif
-
-#if defined(__APPLE__)
-#ifndef WITH_COCOA
-const char* BLI_osx_getBasePath(basePathesTypes pathType)
-{
- return "/tmp/";
-}
-#endif
-#endif
-
static int get_path_user(char *targetpath, char *folder_name, char *envvar)
{
char user_path[FILE_MAX];
-#if defined(WIN32)
- char appdata[FILE_MAX];
-#endif
-
+ const char *user_base_path;
+
user_path[0] = '\0';
if (test_env_path(targetpath, envvar))
return 1;
-
-#if defined(__APPLE__)
- BLI_snprintf(user_path, FILE_MAX, "%s/%s", BLI_osx_getBasePath(BasePath_BlenderUser), blender_version_decimal());
-#elif defined(WIN32)
- if (get_knownfolder_path(appdata, CSIDL_APPDATA)) {
- BLI_snprintf(user_path, FILE_MAX, "%s\\Blender Foundation\\Blender\\%s", appdata, blender_version_decimal());
+
+ user_base_path = (const char *)GHOST_getUserDir();
+ if (user_base_path) {
+ BLI_snprintf(user_path, FILE_MAX, BLENDER_BASE_FORMAT, user_base_path, blender_version_decimal());
}
-#else /* UNIX */
- /* XXX example below - replace with OS API */
- BLI_snprintf(user_path, FILE_MAX, "%s/.blender/%s", BLI_gethome(), blender_version_decimal());
-#endif
if(!user_path[0])
return 0;
@@ -1067,23 +1032,17 @@ static int get_path_user(char *targetpath, char *folder_name, char *envvar)
static int get_path_system(char *targetpath, char *folder_name, char *envvar)
{
char system_path[FILE_MAX];
-#if defined(WIN32)
- char appdata[FILE_MAX];
-#endif
+ const char *system_base_path;
+
+ system_path[0] = '\0';
if (test_env_path(targetpath, envvar))
return 1;
-
-#if defined(__APPLE__)
- BLI_snprintf(system_path, FILE_MAX, "%s/%s", BLI_osx_getBasePath(BasePath_ApplicationBundle), blender_version_decimal());
-#elif defined(WIN32)
- if (get_knownfolder_path(appdata, CSIDL_COMMON_APPDATA)) {
- BLI_snprintf(system_path, FILE_MAX, "%s\\Blender Foundation\\Blender\\%s", appdata, blender_version_decimal());
+
+ system_base_path = (const char *)GHOST_getSystemDir();
+ if (system_base_path) {
+ BLI_snprintf(system_path, FILE_MAX, BLENDER_BASE_FORMAT, system_base_path, blender_version_decimal());
}
-#else /* UNIX */
- /* XXX example below - replace with OS API */
- BLI_snprintf(system_path, FILE_MAX, "/usr/share/blender/%s", blender_version_decimal());
-#endif
if(!system_path[0])
return 0;
diff --git a/source/blender/blenlib/intern/path_util_cocoa.mm b/source/blender/blenlib/intern/path_util_cocoa.mm
deleted file mode 100644
index d12938b2b45..00000000000
--- a/source/blender/blenlib/intern/path_util_cocoa.mm
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * $Id$
- *
- * Functions specific to osx that use API available only in Objective-C
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Damien Plisson 2010
- *
- * ***** END GPL LICENSE BLOCK *****
- *
- */
-
-
-#import <Cocoa/Cocoa.h>
-
-#include <string.h>
-
-#include "BLI_path_util.h"
-
-
-
-/**
- * Gets the ~/Library/Application Data/Blender folder
- */
-const char* BLI_osx_getBasePath(basePathesTypes pathType)
-{
- static char tempPath[512] = "";
-
- NSAutoreleasePool *pool;
- NSString *basePath;
- NSArray *paths;
-
- pool = [[NSAutoreleasePool alloc] init];
-
- switch (pathType) {
- /* Standard pathes */
- case BasePath_Temporary:
- strcpy(tempPath, [NSTemporaryDirectory() cStringUsingEncoding:NSASCIIStringEncoding]);
- [pool drain];
- return tempPath;
- break;
-
- /* Blender specific pathes */
- case BasePath_BlenderShared:
- paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSLocalDomainMask, YES);
- if ([paths count] > 0)
- basePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Blender"];
- else { //Error
- basePath = @"";
- }
- break;
- case BasePath_BlenderUser:
- paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
- if ([paths count] > 0)
- basePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Blender"];
- else { //Error
- basePath = @"";
- }
- break;
- case BasePath_ApplicationBundle:
- basePath = [[NSBundle mainBundle] bundlePath];
- break;
-
- default:
- tempPath[0] = 0;
- [pool drain];
- return tempPath;
- }
-
- strcpy(tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
-
- [pool drain];
- return tempPath;
-}