Page MenuHome

file_paths_04damien78.patch

file_paths_04damien78.patch

Index: intern/ghost/GHOST_C-api.h
===================================================================
--- intern/ghost/GHOST_C-api.h (revision 29797)
+++ intern/ghost/GHOST_C-api.h (working copy)
@@ -836,21 +836,7 @@
*/
extern void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection);
-/**
- * Determine the base dir in which shared resources are located. It will first try to use
- * "unpack and run" path, then look for properly installed path, not including versioning.
- * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
- */
-extern const GHOST_TUns8* GHOST_getSystemDir();
-/**
- * Determine the base dir in which user configuration is stored, not including versioning.
- * If needed, it will create the base directory.
- * @return Unsigned char string pointing to user dir (eg ~/.blender/).
- */
-extern const GHOST_TUns8* GHOST_getUserDir();
-
-
#ifdef __cplusplus
}
#endif
Index: intern/ghost/GHOST_ISystem.h
===================================================================
--- intern/ghost/GHOST_ISystem.h (revision 29797)
+++ intern/ghost/GHOST_ISystem.h (working copy)
@@ -371,24 +371,6 @@
virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 0;
- /***************************************************************************************
- ** Determine special paths.
- ***************************************************************************************/
-
- /**
- * Determine the base dir in which shared resources are located. It will first try to use
- * "unpack and run" path, then look for properly installed path, not including versioning.
- * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
- */
- virtual const GHOST_TUns8* getSystemDir() const = 0;
-
- /**
- * Determine the base dir in which user configuration is stored, not including versioning.
- * If needed, it will create the base directory.
- * @return Unsigned char string pointing to user dir (eg ~/.blender/).
- */
- virtual const GHOST_TUns8* getUserDir() const = 0;
-
protected:
/**
* Initialize the system.
Index: intern/ghost/intern/GHOST_SystemWin32.h
===================================================================
--- intern/ghost/intern/GHOST_SystemWin32.h (revision 29797)
+++ intern/ghost/intern/GHOST_SystemWin32.h (working copy)
@@ -189,20 +189,6 @@
/**
- * Determine the base dir in which shared resources are located. It will first try to use
- * "unpack and run" path, then look for properly installed path, not including versioning.
- * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
- */
- virtual const GHOST_TUns8* getSystemDir() const;
-
- /**
- * Determine the base dir in which user configuration is stored, not including versioning.
- * If needed, it will create the base directory.
- * @return Unsigned char string pointing to user dir (eg ~/.blender/).
- */
- virtual const GHOST_TUns8* getUserDir() const;
-
- /**
* Creates a drag'n'drop event and pushes it immediately onto the event queue.
* Called by GHOST_DropTargetWin32 class.
* @param eventType The type of drag'n'drop event
Index: intern/ghost/intern/GHOST_SystemX11.h
===================================================================
--- intern/ghost/intern/GHOST_SystemX11.h (revision 29797)
+++ intern/ghost/intern/GHOST_SystemX11.h (working copy)
@@ -227,20 +227,6 @@
void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
/**
- * Determine the base dir in which shared resources are located. It will first try to use
- * "unpack and run" path, then look for properly installed path, not including versioning.
- * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
- */
- const GHOST_TUns8* getSystemDir() const;
-
- /**
- * Determine the base dir in which user configuration is stored, not including versioning.
- * If needed, it will create the base directory.
- * @return Unsigned char string pointing to user dir (eg ~/.blender/).
- */
- const GHOST_TUns8* getUserDir() const;
-
- /**
* Atom used for ICCCM, WM-spec and Motif.
* We only need get this atom at the start, it's relative
* to the display not the window and are public for every
Index: intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- intern/ghost/intern/GHOST_SystemWin32.cpp (revision 29797)
+++ intern/ghost/intern/GHOST_SystemWin32.cpp (working copy)
@@ -1092,13 +1092,3 @@
return;
}
}
-
-const GHOST_TUns8* GHOST_SystemWin32::getSystemDir() const
-{
- return NULL;
-}
-
-const GHOST_TUns8* GHOST_SystemWin32::getUserDir() const
-{
- return NULL;
-}
Index: intern/ghost/intern/GHOST_SystemCarbon.h
===================================================================
--- intern/ghost/intern/GHOST_SystemCarbon.h (revision 29797)
+++ intern/ghost/intern/GHOST_SystemCarbon.h (working copy)
@@ -190,20 +190,6 @@
*/
virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
- /**
- * Determine the base dir in which shared resources are located. It will first try to use
- * "unpack and run" path, then look for properly installed path, not including versioning.
- * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
- */
- virtual const GHOST_TUns8* getSystemDir() const;
-
- /**
- * Determine the base dir in which user configuration is stored, not including versioning.
- * If needed, it will create the base directory.
- * @return Unsigned char string pointing to user dir (eg ~/.blender/).
- */
- virtual const GHOST_TUns8* getUserDir() const;
-
protected:
/**
* Initializes the system.
Index: intern/ghost/intern/GHOST_SystemCarbon.cpp
===================================================================
--- intern/ghost/intern/GHOST_SystemCarbon.cpp (revision 29797)
+++ intern/ghost/intern/GHOST_SystemCarbon.cpp (working copy)
@@ -1214,23 +1214,3 @@
CFRelease(textData);
}
}
-
-const GHOST_TUns8* GHOST_SystemCarbon::getSystemDir() const
-{
- return (GHOST_TUns8*)"/Library/Application Support/Blender";
-}
-
-const GHOST_TUns8* GHOST_SystemCarbon::getUserDir() const
-{
- static char usrPath[256] = "";
- char* env = getenv("HOME");
-
- if (env) {
- strncpy(usrPath, env, 245);
- usrPath[245]=0;
- strcat(usrPath, "/Library/Application Support/Blender");
- return (GHOST_TUns8*) usrPath;
- }
- else
- return NULL;
-}
Index: intern/ghost/intern/GHOST_C-api.cpp
===================================================================
--- intern/ghost/intern/GHOST_C-api.cpp (revision 29797)
+++ intern/ghost/intern/GHOST_C-api.cpp (working copy)
@@ -865,15 +865,3 @@
GHOST_ISystem* system = GHOST_ISystem::getSystem();
system->putClipboard(buffer, selection);
}
-
-const GHOST_TUns8* GHOST_getSystemDir()
-{
- GHOST_ISystem* system = GHOST_ISystem::getSystem();
- return system->getSystemDir();
-}
-
-const GHOST_TUns8* GHOST_getUserDir()
-{
- GHOST_ISystem* system = GHOST_ISystem::getSystem();
- return system->getUserDir();
-}
Index: intern/ghost/intern/GHOST_System.h
===================================================================
--- intern/ghost/intern/GHOST_System.h (revision 29797)
+++ intern/ghost/intern/GHOST_System.h (working copy)
@@ -297,20 +297,6 @@
*/
virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 0;
- /**
- * Determine the base dir in which shared resources are located. It will first try to use
- * "unpack and run" path, then look for properly installed path, not including versioning.
- * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
- */
- virtual const GHOST_TUns8* getSystemDir() const = 0;
-
- /**
- * Determine the base dir in which user configuration is stored, not including versioning.
- * If needed, it will create the base directory.
- * @return Unsigned char string pointing to user dir (eg ~/.blender/).
- */
- virtual const GHOST_TUns8* getUserDir() const = 0;
-
protected:
/**
* Initialize the system.
Index: intern/ghost/intern/GHOST_SystemCocoa.h
===================================================================
--- intern/ghost/intern/GHOST_SystemCocoa.h (revision 29797)
+++ intern/ghost/intern/GHOST_SystemCocoa.h (working copy)
@@ -214,20 +214,6 @@
virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
/**
- * Determine the base dir in which shared resources are located. It will first try to use
- * "unpack and run" path, then look for properly installed path, not including versioning.
- * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
- */
- virtual const GHOST_TUns8* getSystemDir() const;
-
- /**
- * Determine the base dir in which user configuration is stored, not including versioning.
- * If needed, it will create the base directory.
- * @return Unsigned char string pointing to user dir (eg ~/.blender/).
- */
- virtual const GHOST_TUns8* getUserDir() const;
-
- /**
* Handles a window event. Called by GHOST_WindowCocoa window delegate
* @param eventType The type of window event
* @param window The window on which the event occured
Index: intern/ghost/intern/GHOST_SystemX11.cpp
===================================================================
--- intern/ghost/intern/GHOST_SystemX11.cpp (revision 29797)
+++ intern/ghost/intern/GHOST_SystemX11.cpp (working copy)
@@ -1458,22 +1458,3 @@
fprintf(stderr, "failed to own primary\n");
}
}
-
-const GHOST_TUns8* GHOST_SystemX11::getSystemDir() const
-{
- return (GHOST_TUns8*)"/usr/share/blender";
-}
-
-const GHOST_TUns8* GHOST_SystemX11::getUserDir() const
-{
- static char path[256];
- char* env = getenv("HOME");
- if(env) {
- strncpy(path, env, 245);
- path[245]=0;
- strcat(path, "/.blender/");
- return (GHOST_TUns8*) path;
- } else {
- return NULL;
- }
-}
Index: intern/ghost/intern/GHOST_SystemCocoa.mm
===================================================================
--- intern/ghost/intern/GHOST_SystemCocoa.mm (revision 29797)
+++ intern/ghost/intern/GHOST_SystemCocoa.mm (working copy)
@@ -1780,61 +1780,3 @@
[pool drain];
}
-
-#pragma mark Base directories retrieval
-
-const GHOST_TUns8* GHOST_SystemCocoa::getSystemDir() const
-{
- static GHOST_TUns8 tempPath[512] = "";
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSFileManager *fileManager;
- NSString *basePath;
- NSArray *paths;
-
- paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSLocalDomainMask, YES);
-
- if ([paths count] > 0)
- basePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Blender"];
- else { //Fall back to standard unix path in case of issue
- basePath = @"/usr/share/blender";
- }
-
- /* Ensure path exists, creates it if needed */
- fileManager = [NSFileManager defaultManager];
- if (![fileManager fileExistsAtPath:basePath isDirectory:NULL]) {
- [fileManager createDirectoryAtPath:basePath attributes:nil];
- }
-
- strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
-
- [pool drain];
- return tempPath;
-}
-
-const GHOST_TUns8* GHOST_SystemCocoa::getUserDir() const
-{
- static GHOST_TUns8 tempPath[512] = "";
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSFileManager *fileManager;
- NSString *basePath;
- NSArray *paths;
-
- paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
-
- if ([paths count] > 0)
- basePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Blender"];
- else { //Fall back to HOME in case of issue
- basePath = [NSHomeDirectory() stringByAppendingPathComponent:@".blender"];
- }
-
- /* Ensure path exists, creates it if needed */
- fileManager = [NSFileManager defaultManager];
- if (![fileManager fileExistsAtPath:basePath isDirectory:NULL]) {
- [fileManager createDirectoryAtPath:basePath attributes:nil];
- }
-
- strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
-
- [pool drain];
- return tempPath;
-}
Index: source/creator/CMakeLists.txt
===================================================================
--- source/creator/CMakeLists.txt (revision 29797)
+++ source/creator/CMakeLists.txt (working copy)
@@ -210,18 +210,16 @@
COMMAND cp -Rf ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
COMMAND cp -Rf ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
- COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/.blender
- COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
- COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
+ COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/datafiles
+ COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/
+ COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/
)
IF(WITH_INTERNATIONAL)
ADD_CUSTOM_COMMAND(
TARGET blender POST_BUILD MAIN_DEPENDENCY blender
- COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
- COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/Resources/
- COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
- COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/Resources/
+ COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/
+ COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/
)
ENDIF(WITH_INTERNATIONAL)
@@ -233,9 +231,10 @@
ENDIF(WITH_LIBS10.5)
ADD_CUSTOM_COMMAND(
TARGET blender POST_BUILD MAIN_DEPENDENCY blender
- COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
- COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/
- COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/
+ COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/scripts/
+ COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/python/
+ COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/python/
+ COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/python/
COMMAND find ${TARGETDIR}/blender.app -name "*.py?" -prune -exec rm -rf {} "\;"
)
ENDIF(WITH_PYTHON)
Index: source/blender/blenkernel/intern/blender.c
===================================================================
--- source/blender/blenkernel/intern/blender.c (revision 29797)
+++ source/blender/blenkernel/intern/blender.c (working copy)
@@ -55,6 +55,7 @@
#include "BLI_blenlib.h"
#include "BLI_dynstr.h"
+#include "BLI_path_util.h"
#include "IMB_imbuf.h"
@@ -362,7 +363,7 @@
BlendFileData *bfd;
int retval= 1;
- if(strstr(dir, ".B25.blend")==0) /* dont print user-pref loading */
+ if(strstr(dir, BLENDER_STARTUP_FILE)==0) /* dont print user-pref loading */
printf("read blend: %s\n", dir);
bfd= BLO_read_from_file(dir, reports);
Index: source/blender/python/intern/bpy_interface.c
===================================================================
--- source/blender/python/intern/bpy_interface.c (revision 29797)
+++ source/blender/python/intern/bpy_interface.c (working copy)
@@ -177,7 +177,7 @@
/* must be called before Py_Initialize */
void BPY_start_python_path(void)
{
- char *py_path_bundle= BLI_gethome_folder("python", BLI_GETHOME_ALL);
+ char *py_path_bundle= BLI_get_folder(BLENDER_PYTHON, NULL);
if(py_path_bundle==NULL)
return;
Index: source/blender/python/intern/bpy.c
===================================================================
--- source/blender/python/intern/bpy.c (revision 29797)
+++ source/blender/python/intern/bpy.c (working copy)
@@ -145,7 +145,7 @@
PyObject *mod;
/* Needs to be first since this dir is needed for future modules */
- char *modpath= BLI_gethome_folder("scripts/modules", BLI_GETHOME_ALL);
+ char *modpath= BLI_get_folder(BLENDER_SCRIPTS, "modules");
if(modpath) {
// printf("bpy: found module path '%s'.\n", modpath);
PyObject *sys_path= PySys_GetObject("path"); /* borrow */
Index: source/blender/windowmanager/intern/wm_files.c
===================================================================
--- source/blender/windowmanager/intern/wm_files.c (revision 29797)
+++ source/blender/windowmanager/intern/wm_files.c (working copy)
@@ -329,17 +329,14 @@
{
ListBase wmbase;
char tstr[FILE_MAXDIR+FILE_MAXFILE], scestr[FILE_MAXDIR];
- char *home= BLI_gethome();
int from_memory= op?RNA_boolean_get(op->ptr, "factory"):0;
int success;
-
- BLI_clean(home);
free_ttfont(); /* still weird... what does it here? */
G.relbase_valid = 0;
if (!from_memory) {
- BLI_make_file_string(G.sce, tstr, home, ".B25.blend");
+ BLI_make_file_string(G.sce, tstr, BLI_get_folder(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
}
strcpy(scestr, G.sce); /* temporary store */
@@ -395,7 +392,7 @@
char *line;
int num;
- BLI_make_file_string("/", name, BLI_gethome(), ".Blog");
+ BLI_make_file_string("/", name, BLI_get_folder(BLENDER_CONFIG, NULL), BLENDER_HISTORY_FILE);
lines= BLI_read_file_as_lines(name);
G.recent_files.first = G.recent_files.last = NULL;
@@ -431,7 +428,7 @@
FILE *fp;
int i;
- BLI_make_file_string("/", name, BLI_gethome(), ".Blog");
+ BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_HISTORY_FILE);
recent = G.recent_files.first;
/* refresh .Blog of recent opened files, when current file was changed */
@@ -648,7 +645,8 @@
if(win->screen->full == SCREENTEMP)
wm_window_close(C, wm, win);
- BLI_make_file_string("/", tstr, BLI_gethome(), ".B25.blend");
+ BLI_make_file_string("/", tstr, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
+ printf("trying to save homefile at %s \n", tstr);
/* force save as regular blend file */
fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN);
Index: source/blender/blenlib/BLI_path_util.h
===================================================================
--- source/blender/blenlib/BLI_path_util.h (revision 29797)
+++ source/blender/blenlib/BLI_path_util.h (working copy)
@@ -45,6 +45,58 @@
#define BLI_GETHOME_USER 1<<3 /* home folder ~/.blender */
#define BLI_GETHOME_ALL (BLI_GETHOME_SYSTEM|BLI_GETHOME_LOCAL|BLI_GETHOME_USER)
+
+#ifdef __APPLE__
+typedef enum {
+ BasePath_Temporary = 1,
+ BasePath_BlenderShared,
+ BasePath_BlenderUser,
+ BasePath_ApplicationBundle
+} basePathesTypes;
+
+/**
+ * Gets the base path. The path may not exist.
+ * Note that return string must be copied as its persistence is not guaranteed
+ *
+ * @return base path of pathType
+ */
+const char* BLI_osx_getBasePath(basePathesTypes pathType);
+#endif
+
+char *BLI_get_folder(int folder_id, char *subfolder);
+char *BLI_get_folder_create(int folder_id, char *subfolder);
+
+/* folder_id */
+
+/* general, will find baserd on user/local/system priority */
+#define BLENDER_CONFIG 1
+#define BLENDER_DATAFILES 2
+#define BLENDER_SCRIPTS 3
+#define BLENDER_PLUGINS 4
+#define BLENDER_PYTHON 5
+
+/* user-specific */
+#define BLENDER_USER_CONFIG 31
+#define BLENDER_USER_DATAFILES 32
+#define BLENDER_USER_SCRIPTS 33
+#define BLENDER_USER_PLUGINS 34
+
+/* system */
+#define BLENDER_SYSTEM_CONFIG 51 /* optional */
+#define BLENDER_SYSTEM_DATAFILES 52
+#define BLENDER_SYSTEM_SCRIPTS 53
+#define BLENDER_SYSTEM_PLUGINS 54
+#define BLENDER_SYSTEM_PYTHON 54
+
+#define BLENDER_TEMP 80
+
+#define BLENDER_USERFOLDER(id) (id >= BLENDER_USER_CONFIG && id <= BLENDER_USER_PLUGINS)
+
+#define BLENDER_STARTUP_FILE "startup.blend"
+#define BLENDER_BOOKMARK_FILE "bookmarks.txt"
+#define BLENDER_HISTORY_FILE "recent-files.txt"
+
+
void BLI_setenv(const char *env, const char *val);
void BLI_setenv_if_new(const char *env, const char* val);
@@ -135,15 +187,6 @@
void BLI_where_is_temp(char *fullname, int usertemp);
- /**
- * determines the full path to the application bundle on OS X
- *
- * @return path to application bundle
- */
-#ifdef __APPLE__
-char* BLI_getbundle(void);
-#endif
-
#ifdef WITH_ICONV
void BLI_string_to_utf8(char *original, char *utf_8, const char *code);
#endif
Index: source/blender/blenlib/CMakeLists.txt
===================================================================
--- source/blender/blenlib/CMakeLists.txt (revision 29797)
+++ source/blender/blenlib/CMakeLists.txt (working copy)
@@ -33,6 +33,10 @@
${ZLIB_INC}
)
+IF(APPLE)
+ SET(SRC ${SRC} intern/path_util_cocoa.m)
+ENDIF(APPLE)
+
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
SET(INC
${INC}
Index: source/blender/blenlib/intern/path_util_cocoa.m
===================================================================
--- source/blender/blenlib/intern/path_util_cocoa.m (revision 0)
+++ source/blender/blenlib/intern/path_util_cocoa.m (revision 0)
@@ -0,0 +1,96 @@
+/* path_util_cocoa.m
+ *
+ * Functions specific to osx that use API available only in Objective-C
+ *
+ *
+ * $Id: util_cocoa.m 25007 2009-11-29 19:16:52Z kazanbas $
+ *
+ * ***** 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;
+}
\ No newline at end of file
Index: source/blender/blenlib/intern/BLI_bfile.c
===================================================================
--- source/blender/blenlib/intern/BLI_bfile.c (revision 29797)
+++ source/blender/blenlib/intern/BLI_bfile.c (working copy)
@@ -48,8 +48,6 @@
#include "BLI_storage.h"
#include "BLI_bfile.h"
-#include "GHOST_C-api.h"
-
/* Internal bfile classification flags */
#define BCF_OPEN (0)
#define BCF_FOPEN (1<<0)
@@ -64,12 +62,8 @@
/* Declaration of internal functions */
-static void chomp(char* line);
-static void expand_envvars(char* src, char* dst);
static void fill_paths(BFILE *bfile, const char *path, const char *relpath);
-static void init_vars_from_file(const char* path);
static void free_paths(BFILE* bfile);
-static void setup_temp();
/*** Exported functions ***/
@@ -274,205 +268,9 @@
}
-void BLI_bfile_init_vars() {
- char file[MAXPATHLEN];
- char temp[MAXPATHLEN];
- extern char bprogname[];
- FILE* fp;
-
- /* This one is unconditional */
- sprintf(temp, "%d", BLENDER_VERSION);
- BLI_setenv("BLENDER_VERSION", temp);
-
- /* Is this unpack&run? */
- sprintf(temp, "%s/%d/environment", dirname(bprogname), BLENDER_VERSION);
- if (BLI_exist(temp)) {
- BLI_setenv_if_new("BLENDER_SHARE", dirname(bprogname));
- } else {
- BLI_setenv_if_new("BLENDER_SHARE", (const char*)GHOST_getSystemDir());
- }
-
- strcpy(file, (const char*)GHOST_getUserDir());
- BLI_add_slash(file);
- strcat(file, LAST_SESSION_FILE);
- fp = fopen(file, "r");
- /* 1st line, read previous version */
- if (fp && (fscanf(fp, "%3c\n", temp) == 1)) {
- temp[3] = '\0';
- BLI_setenv("BLENDER_VERSION_PREV", temp);
- /* 2nd line, read previous session path if needed */
- if (!getenv("BLENDER_TEMP")) {
- if ((fgets(temp, MAXPATHLEN, fp) != NULL)) {
- /* Clean any \n */
- chomp(temp);
- /* Check the dir is still there or generate new one */
- if (!BLI_exist(temp)) {
- setup_temp();
- }
- } else {
- /* We have to generate it for sure */
- setup_temp();
- }
- }
- } else {
- /* Probably new user, or only <=249 before */
- BLI_setenv("BLENDER_VERSION_PREV", "0");
- setup_temp();
- }
-
- if (fp) {
- fclose(fp);
- }
-
- /* Loaded session info (or created), so time to store current data */
- // TODO use own fuctions to get safe saving
- fp = fopen(file, "w");
- if (fp) {
- fprintf(fp, "%s\n%s\n", getenv("BLENDER_VERSION"), getenv("BLENDER_TEMP"));
- fclose(fp);
- }
-
- /* Load vars from user and system files */
- strcpy(file, (const char *)GHOST_getUserDir());
- BLI_add_slash(file);
- strcat(file, ENVIRONMENT_FILE);
- init_vars_from_file(file);
- sprintf(temp, "/%d/environment", BLENDER_VERSION);
- BLI_make_file_string("/", file, getenv("BLENDER_SHARE"), temp);
- init_vars_from_file(file);
-}
-
-
/*** Internal functions ***/
/**
- Eliminate trailing EOL by writing a \0 over it.
- Name taken from Perl.
- */
-static void chomp(char* line) {
- int len = strlen(line);
-#ifndef WIN32
- if (line[len - 1] == '\n') {
- line[len - 1] = '\0';
- }
-#else
- if ((line[len - 2] == '\r' ) && ((line[len - 1] == '\n'))) {
- line[len - 2] = '\0';
- }
-#endif /* WIN32 */
-}
-
-
-/**
- Parse a file with lines like FOO=bar (comment lines have # as first
- character) assigning to envvar FOO the value bar if FOO does not
- exist yet.
- Any white space before FOO, around the = or trailing will be used,
- so beware.
- */
-#define MAX_LINE 4096
-#define ENV_VAR 256
-#define VAR_LEN 8192
-static void init_vars_from_file(const char* path) {
- char line[MAX_LINE];
- char name[ENV_VAR];
- FILE *fp;
- char* separator;
- char expanded[VAR_LEN];
-
- fp = fopen(path, "r");
- if (!fp) return;
-
- while (fgets(line, MAX_LINE, fp) != NULL) {
- /* Ignore comment lines */
- if (line[0] == '#')
- continue;
-
- /* Split into envvar name and contents */
- separator = strchr(line, '=');
- if (separator && ((separator - line) < ENV_VAR)) {
- /* First remove EOL */
- chomp(line);
- strncpy(name, line, separator - line);
- name[separator - line] = '\0';
- expand_envvars(separator + 1, expanded);
- BLI_setenv_if_new(name, expanded);
- }
- }
- fclose(fp);
-}
-
-
-/**
- Look for ${} (or %%) env vars in src and expand if the var
- exists (even if empty value). If not exist, the name is left as is.
- The process is done all over src, and nested ${${}} is not supported.
- src must be \0 terminated, and dst must be big enough.
-*/
-#ifndef WIN32
- #define ENVVAR_PREFFIX "${"
- #define ENVVAR_P_SIZE 2
- #define ENVVAR_SUFFIX "}"
- #define ENVVAR_S_SIZE 1
-#else
- #define ENVVAR_PREFFIX "%"
- #define ENVVAR_P_SIZE 1
- #define ENVVAR_SUFFIX "%"
- #define ENVVAR_S_SIZE 1
-#endif /* WIN32 */
-static void expand_envvars(char* src, char* dst) {
- char* hit1;
- char* hit2;
- char name[ENV_VAR];
- char* value;
- int prevlen;
- int done = 0;
- char* source = src;
-
- dst[0] = '\0';
- while (!done) {
- hit1 = strstr(source, ENVVAR_PREFFIX);
- if (hit1) {
- hit2 = strstr(hit1 + ENVVAR_P_SIZE, ENVVAR_SUFFIX);
- if (hit2) {
- /* "Copy" the leading part, if any */
- if (hit1 != source) {
- prevlen = strlen(dst);
- strncat(dst, source, hit1 - source);
- dst[prevlen + (hit1 - source)] = '\0';
- }
- /* Figure the name of the env var we just found */
- strncpy(name, hit1 + ENVVAR_P_SIZE,
- hit2 - (hit1 + ENVVAR_P_SIZE));
- name[hit2 - (hit1 + ENVVAR_P_SIZE)] = '\0';
- /* See if we can get something with that name */
- value = getenv(name);
- if (value) {
- /* Push the var value */
- strcat(dst, value);
- } else {
- /* Leave the var name, so it is clear that it failed */
- strcat(dst, ENVVAR_PREFFIX);
- strcat(dst, name);
- strcat(dst, ENVVAR_SUFFIX);
- }
- /* Continue after closing mark, like a new string */
- source = hit2 + ENVVAR_S_SIZE;
- } else {
- /* Non terminated var so "copy as is" and finish */
- strcat(dst, source);
- done = 1;
- }
- } else {
- /* "Copy" whatever is left */
- strcat(dst, source);
- done = 1;
- }
- }
-}
-
-
-/**
Return a full path if the filename exists when combined
with any item from pathlist. Or NULL otherwise.
*/
@@ -572,24 +370,3 @@
MEM_freeN(bfile->tpath);
}
}
-
-
-/**
- Create a temp directory in safe and multiuser way.
- */
-static void setup_temp() {
- char template[MAXPATHLEN];
- char* tempdir;
-
- if (getenv("TMPDIR")) {
- sprintf(template, "%s/blender-XXXXXX", getenv("TMPDIR"));
- } else {
- sprintf(template, "/tmp/blender-XXXXXX");
-// MacOSX NSTemporaryDirectory and WIN32 ???
-// https://bugs.launchpad.net/cuneiform-linux/+bug/267136
-// https://svn.r-project.org/R/trunk/src/main/mkdtemp.c
- }
- tempdir = mkdtemp(template);
- BLI_setenv("BLENDER_TEMP", tempdir);
-}
-
Index: source/blender/blenlib/intern/path_util.c
===================================================================
--- source/blender/blenlib/intern/path_util.c (revision 29797)
+++ source/blender/blenlib/intern/path_util.c (working copy)
@@ -44,6 +44,7 @@
#include "BLI_storage_types.h"
#include "BKE_utildefines.h"
+#include "BKE_blender.h" // BLENDER_VERSION
@@ -63,11 +64,6 @@
#else /* non windows */
-#ifdef __APPLE__
-#include <sys/param.h>
-#include <CoreFoundation/CoreFoundation.h>
-#endif
-
#ifdef __linux__
#include "binreloc.h"
#endif
@@ -765,7 +761,11 @@
}
- /* add user profile support for WIN 2K / NT */
+ /* add user profile support for WIN 2K / NT.
+ * This is %APPDATA%, which translates to either
+ * %USERPROFILE%\Application Data or since Vista
+ * to %USERPROFILE%\AppData\Roaming
+ */
hResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdatapath);
if (hResult == S_OK)
@@ -800,7 +800,7 @@
/* this function returns the path to a blender folder, if it exists
* utility functions for BLI_gethome_folder */
-/* #define PATH_DEBUG */ /* for testing paths that are checked */
+// #define PATH_DEBUG /* for testing paths that are checked */
static int test_data_path(char *targetpath, char *path_base, char *path_sep, char *folder_name)
{
@@ -911,6 +911,281 @@
return NULL;
}
+
+/* NEW stuff, to be cleaned up when fully migrated */
+/* ************************************************************* */
+/* ************************************************************* */
+
+#define PATH_DEBUG2
+
+static char *blender_version_decimal(void)
+{
+ static char version_str[5];
+ sprintf(version_str, "%d.%02d", BLENDER_VERSION/100, BLENDER_VERSION%100);
+ return version_str;
+}
+
+static int test_path(char *targetpath, char *path_base, char *path_sep, char *folder_name)
+{
+ char tmppath[FILE_MAX];
+
+ if(path_sep) BLI_join_dirfile(tmppath, path_base, path_sep);
+ else BLI_strncpy(tmppath, path_base, sizeof(tmppath));
+
+ BLI_make_file_string("/", targetpath, tmppath, folder_name);
+
+ if (BLI_exists(targetpath)) {
+#ifdef PATH_DEBUG2
+ printf("\tpath found: %s\n", targetpath);
+#endif
+ return 1;
+ }
+ else {
+#ifdef PATH_DEBUG2
+ printf("\tpath missing: %s\n", targetpath);
+#endif
+ //targetpath[0] = '\0';
+ return 0;
+ }
+}
+
+static int test_env_path(char *path, char *envvar)
+{
+ char *env = envvar?getenv(envvar):NULL;
+ if (!env) return 0;
+
+ if (BLI_exists(env)) {
+ BLI_strncpy(path, env, FILE_MAX);
+ return 1;
+ } else {
+ path[0] = '\0';
+ return 0;
+ }
+}
+
+static int get_path_local(char *targetpath, char *folder_name)
+{
+ extern char bprogname[]; /* argv[0] from creator.c */
+ char bprogdir[FILE_MAX];
+ char cwd[FILE_MAX];
+ char *s;
+ int i;
+
+#ifdef PATH_DEBUG2
+ printf("get_path_local...\n");
+#endif
+
+
+ /* use argv[0] (bprogname) to get the path to the executable */
+ s = BLI_last_slash(bprogname);
+ i = s - bprogname + 1;
+ BLI_strncpy(bprogdir, bprogname, i);
+
+ /* try EXECUTABLE_DIR/folder_name */
+ if(test_path(targetpath, bprogdir, "", folder_name))
+ return 1;
+
+ /* try CWD/release/folder_name */
+ if(test_path(targetpath, BLI_getwdN(cwd), "release", folder_name))
+ return 1;
+
+ /* try EXECUTABLE_DIR/release/folder_name */
+ if(test_path(targetpath, bprogdir, "release", folder_name))
+ return 1;
+
+ /* try ./.blender/folder_name -- DEPRECATED, need to update build systems */
+ if(test_path(targetpath, bprogdir, ".blender", folder_name))
+ return 1;
+
+ return 0;
+}
+
+static int get_path_user(char *targetpath, char *folder_name, char *envvar)
+{
+ char user_path[FILE_MAX];
+ char *ret;
+
+ if (test_env_path(targetpath, envvar))
+ return 1;
+
+#if defined(__APPLE__)
+ BLI_strncpy(user_path, BLI_osx_getBasePath(BasePath_BlenderUser), FILE_MAXDIR);
+
+#elif defined(WIN32)
+ /* Get %USERPROFILE%, append .blender */
+ BLI_strncpy(user_path, getenv("USERPROFILE"), FILE_MAXDIR);
+ strcat(user_path, "\\.blender");
+ if(!BLI_exists(user_path)) {
+ }
+ printf("USERPATH: %s\n", user_path);
+
+#else /* UNIX */
+ /* XXX example below - replace with OS API */
+ BLI_strncpy(user_path, BLI_gethome(), FILE_MAXDIR);
+ strcat(user_path, "/.blender");
+#endif
+
+ if(!user_path[0])
+ return 0;
+
+ BLI_add_slash(user_path);
+ strcat(user_path, blender_version_decimal());
+ BLI_add_slash(user_path);
+
+
+#ifdef PATH_DEBUG2
+ printf("get_path_user: %s\n", user_path);
+#endif
+
+ /* try $HOME/folder_name */
+ return test_path(targetpath, user_path, NULL, folder_name);
+}
+
+static int get_path_system(char *targetpath, char *folder_name, char *envvar)
+{
+ char *system_path;
+ char sys_path[FILE_MAXDIR];
+
+ if (test_env_path(targetpath, envvar))
+ return 1;
+
+#if defined(__APPLE__)
+ BLI_strncpy(sys_path, BLI_osx_getBasePath(BasePath_ApplicationBundle), FILE_MAXDIR);
+ system_path = sys_path;
+
+#elif defined(WIN32)
+ /* XXX example below - replace with OS API */
+ //system_path = BLI_getInstallationDir();
+ BLI_strncpy(sys_path, getenv("ALLUSERPROFILE"), FILE_MAXDIR);
+ strcat(sys_path, "\\Blender\\System");
+ printf("SYSTEMPATH: %s\n", sys_path);
+ system_path = sys_path;
+#else /* UNIX */
+ /* XXX example below - replace with OS API */
+ BLI_strncpy(sys_path,"/usr/share/blender/",FILE_MAXDIR);
+ system_path = sys_path;
+#endif
+
+ if(!system_path[0])
+ return 0;
+
+ BLI_add_slash(system_path);
+ strcat(system_path, blender_version_decimal());
+ BLI_add_slash(system_path);
+
+
+#ifdef PATH_DEBUG2
+ printf("get_path_system: %s\n", system_path);
+#endif
+
+ /* try $BLENDERPATH/folder_name */
+ return test_path(targetpath, system_path, NULL, folder_name);
+}
+
+/* get a folder out of the 'folder_id' presets for paths */
+/* returns the path if found, NULL string if not */
+char *BLI_get_folder(int folder_id, char *subfolder)
+{
+ static char path[FILE_MAX] = "";
+ char search_path[FILE_MAX];
+
+ switch (folder_id) {
+ case BLENDER_DATAFILES: /* general case */
+ BLI_join_dirfile(search_path, "datafiles", subfolder);
+ if (get_path_user(path, search_path, "BLENDER_USER_DATAFILES")) break;
+ if (get_path_local(path, search_path)) break;
+ if (get_path_system(path, search_path, "BLENDER_SYSTEM_DATAFILES")) break;
+ return NULL;
+
+ case BLENDER_USER_DATAFILES:
+ BLI_join_dirfile(search_path, "datafiles", subfolder);
+ if (get_path_user(path, search_path, "BLENDER_USER_DATAFILES")) break;
+ return NULL;
+
+ case BLENDER_SYSTEM_DATAFILES:
+ BLI_join_dirfile(search_path, "datafiles", subfolder);
+ if (get_path_system(path, search_path, "BLENDER_SYSTEM_DATAFILES")) break;
+ return NULL;
+
+ case BLENDER_CONFIG: /* general case */
+ BLI_join_dirfile(search_path, "config", subfolder);
+ if (get_path_user(path, search_path, "BLENDER_USER_CONFIG")) break;
+ if (get_path_local(path, search_path)) break;
+ if (get_path_system(path, search_path, "BLENDER_SYSTEM_CONFIG")) break;
+ return NULL;
+
+ case BLENDER_USER_CONFIG:
+ BLI_join_dirfile(search_path, "config", subfolder);
+ if (get_path_user(path, search_path, "BLENDER_USER_CONFIG")) break;
+ return NULL;
+
+ case BLENDER_SYSTEM_CONFIG:
+ BLI_join_dirfile(search_path, "config", subfolder);
+ if (get_path_system(path, search_path, "BLENDER_SYSTEM_CONFIG")) break;
+ return NULL;
+
+ case BLENDER_SCRIPTS: /* general case */
+ BLI_join_dirfile(search_path, "scripts", subfolder);
+ if (get_path_user(path, search_path, "BLENDER_USER_SCRIPTS")) break;
+ if (get_path_local(path, search_path)) break;
+ if (get_path_system(path, search_path, "BLENDER_SYSTEM_SCRIPTS")) break;
+ return NULL;
+
+ case BLENDER_USER_SCRIPTS:
+ BLI_join_dirfile(search_path, "scripts", subfolder);
+ if (get_path_user(path, search_path, "BLENDER_USER_SCRIPTS")) break;
+ return NULL;
+
+ case BLENDER_SYSTEM_SCRIPTS:
+ BLI_join_dirfile(search_path, "scripts", subfolder);
+ if (get_path_system(path, search_path, "BLENDER_SYSTEM_SCRIPTS")) break;
+ return NULL;
+
+ case BLENDER_PYTHON: /* general case */
+ BLI_join_dirfile(search_path, "python", subfolder);
+ if (get_path_local(path, search_path)) break;
+ if (get_path_system(path, search_path, "BLENDER_SYSTEM_PYTHON")) break;
+ return NULL;
+
+ case BLENDER_SYSTEM_PYTHON:
+ BLI_join_dirfile(search_path, "scripts", subfolder);
+
+ if (get_path_system(path, search_path, "BLENDER_SYSTEM_PYTHON")) break;
+ return NULL;
+ }
+
+ return path;
+}
+
+char *BLI_get_folder_create(int folder_id, char *subfolder)
+{
+ char *path;
+
+ /* only for user folders */
+ if (!ELEM(folder_id, BLENDER_USER_DATAFILES, BLENDER_USER_CONFIG))
+ return NULL;
+
+ path = BLI_get_folder(folder_id, subfolder);
+
+ if (path) {
+ BLI_recurdir_fileops(path);
+ }
+ else {
+#ifdef WIN32
+ SHCreateDirectoryEx(NULL, path, NULL);
+#endif
+ }
+
+ return path;
+}
+
+
+/* End new stuff */
+/* ************************************************************* */
+/* ************************************************************* */
+
+
+
#ifdef PATH_DEBUG
#undef PATH_DEBUG
#endif
@@ -1164,6 +1439,9 @@
if(string != dir) /* compare pointers */
BLI_strncpy(string, dir, FILE_MAX);
+
+ if (!file)
+ return;
sl_dir= BLI_add_slash(string);
@@ -1471,26 +1749,6 @@
}
}
-/*
- * returns absolute path to the app bundle
- * only useful on OS X
- */
-#ifdef __APPLE__
-char* BLI_getbundle(void) {
- CFURLRef bundleURL;
- CFStringRef pathStr;
- static char path[MAXPATHLEN];
- CFBundleRef mainBundle = CFBundleGetMainBundle();
-
- bundleURL = CFBundleCopyBundleURL(mainBundle);
- pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
- CFStringGetCString(pathStr, path, MAXPATHLEN, kCFStringEncodingASCII);
- CFRelease(pathStr);
- CFRelease(bundleURL);
- return path;
-}
-#endif
-
#ifdef WITH_ICONV
void BLI_string_to_utf8(char *original, char *utf_8, const char *code)
Index: source/blender/blenloader/intern/writefile.c
===================================================================
--- source/blender/blenloader/intern/writefile.c (revision 29797)
+++ source/blender/blenloader/intern/writefile.c (working copy)
@@ -2502,7 +2502,7 @@
makeFilesAbsolute(G.sce, NULL);
}
- BLI_make_file_string(G.sce, userfilename, BLI_gethome(), ".B25.blend");
+ BLI_make_file_string(G.sce, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
write_user_block= BLI_streq(dir, userfilename);
if(write_flags & G_FILE_RELATIVE_REMAP)
Index: source/blender/blenfont/intern/blf_lang.c
===================================================================
--- source/blender/blenfont/intern/blf_lang.c (revision 29797)
+++ source/blender/blenfont/intern/blf_lang.c (working copy)
@@ -59,66 +59,20 @@
char global_language[32];
char global_encoding_name[32];
-#if defined(__APPLE__)
-void BLF_lang_init(void) /* Apple Only, todo - use BLI_gethome_folder */
-{
- char *bundlepath;
- strcpy(global_encoding_name, SYSTEM_ENCODING_DEFAULT);
-
- /* set messagepath directory */
-#ifndef LOCALEDIR
-#define LOCALEDIR "/usr/share/locale"
-#endif
-
- strcpy(global_messagepath, ".blender/locale");
-
- if (!BLI_exist(global_messagepath)) { /* locale not in current dir */
- BLI_make_file_string("/", global_messagepath, BLI_gethome(), ".blender/locale");
-
- if (!BLI_exist(global_messagepath)) { /* locale not in home dir */
- /* message catalogs are stored inside the application bundle */
- bundlepath= BLI_getbundle();
- strcpy(global_messagepath, bundlepath);
- strcat(global_messagepath, "/Contents/Resources/locale");
- if (!BLI_exist(global_messagepath)) { /* locale not in bundle (now that's odd..) */
- strcpy(global_messagepath, LOCALEDIR);
-
- if (!BLI_exist(global_messagepath)) { /* locale not in LOCALEDIR */
- strcpy(global_messagepath, "message"); /* old compatibility as last */
- }
- }
- }
- }
-}
-#elif defined(_WIN32)
-void BLF_lang_init(void) /* Windows Only, todo - use BLI_gethome_folder */
+void BLF_lang_init(void)
{
- strcpy(global_encoding_name, SYSTEM_ENCODING_DEFAULT);
+ char *messagepath= BLI_get_folder(BLENDER_DATAFILES, "locale");
- strcpy(global_messagepath, ".blender/locale");
-
- if (!BLI_exist(global_messagepath)) { /* locale not in current dir */
- BLI_make_file_string("/", global_messagepath, BLI_gethome(), ".blender/locale");
-
- if (!BLI_exist(global_messagepath)) { /* locale not in home dir */
- BLI_make_file_string("/", global_messagepath, BLI_gethome(), "/locale");
- }
- }
-}
-#else
-void BLF_lang_init(void) /* not win or mac */
-{
- char *messagepath= BLI_gethome_folder("locale", BLI_GETHOME_ALL);
+ BLI_strncpy(global_encoding_name, SYSTEM_ENCODING_DEFAULT, sizeof(global_encoding_name));
- if(messagepath)
- strncpy(global_messagepath, messagepath, sizeof(global_messagepath));
+ if (messagepath)
+ BLI_strncpy(global_messagepath, messagepath, sizeof(global_messagepath));
else
global_messagepath[0]= '\0';
-
}
-#endif
+
void BLF_lang_set(const char *str)
{
#if defined (_WIN32) || defined(__APPLE__)
Index: source/blender/editors/space_file/file_ops.c
===================================================================
--- source/blender/editors/space_file/file_ops.c (revision 29797)
+++ source/blender/editors/space_file/file_ops.c (working copy)
@@ -391,7 +391,7 @@
char name[FILE_MAX];
fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, 0, 1);
- BLI_make_file_string("/", name, BLI_gethome(), ".Bfs");
+ BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu, name);
}
@@ -423,7 +423,7 @@
char name[FILE_MAX];
fsmenu_remove_entry(fsmenu, FS_CATEGORY_BOOKMARKS, index);
- BLI_make_file_string("/", name, BLI_gethome(), ".Bfs");
+ BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu, name);
ED_area_tag_redraw(sa);
}
@@ -619,7 +619,7 @@
folderlist_free(sfile->folders_next);
fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir,0, 1);
- BLI_make_file_string(G.sce, filepath, BLI_gethome(), ".Bfs");
+ BLI_make_file_string(G.sce, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu_get(), filepath);
WM_event_fileselect_event(C, op, EVT_FILESELECT_EXEC);
Index: source/blender/editors/space_file/space_file.c
===================================================================
--- source/blender/editors/space_file/space_file.c (revision 29797)
+++ source/blender/editors/space_file/space_file.c (working copy)
@@ -592,7 +592,7 @@
void ED_file_init(void)
{
char name[FILE_MAX];
- BLI_make_file_string("/", name, BLI_gethome(), ".Bfs");
+ BLI_make_file_string("/", name, BLI_get_folder(BLENDER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_read_file(fsmenu_get(), name);
filelist_init_icons();
IMB_thumb_makedirs();
Index: source/blender/editors/interface/interface_icons.c
===================================================================
--- source/blender/editors/interface/interface_icons.c (revision 29797)
+++ source/blender/editors/interface/interface_icons.c (working copy)
@@ -460,15 +460,8 @@
char filenamestr[FILE_MAXFILE+16]; // 16 == strlen(".blender/icons/")+1
if ((btheme!=NULL) && (strlen(btheme->tui.iconfile) > 0)) {
-
-#ifdef WIN32
- sprintf(filenamestr, "icons/%s", btheme->tui.iconfile);
-#else
- sprintf(filenamestr, ".blender/icons/%s", btheme->tui.iconfile);
-#endif
+ BLI_make_file_string("/", iconfilestr, BLI_get_folder(BLENDER_DATAFILES, NULL), btheme->tui.iconfile);
- BLI_make_file_string("/", iconfilestr, BLI_gethome(), filenamestr);
-
if (BLI_exists(iconfilestr)) {
bbuf = IMB_loadiffname(iconfilestr, IB_rect);
if(bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H) {
@@ -558,11 +551,7 @@
list->first = list->last = NULL;
-#ifdef WIN32
- BLI_make_file_string("/", icondirstr, BLI_gethome(), "icons");
-#else
- BLI_make_file_string("/", icondirstr, BLI_gethome(), ".blender/icons");
-#endif
+ BLI_make_file_string("/", icondirstr, BLI_get_folder(BLENDER_DATAFILES, NULL), "");
if(BLI_exists(icondirstr)==0)
return;
Index: SConstruct
===================================================================
--- SConstruct (revision 29797)
+++ SConstruct (working copy)
@@ -437,6 +437,8 @@
#-- .blender
#- dont do .blender and scripts for darwin, it is already in the bundle
dotblendlist = []
+datafileslist = []
+datafilestargetlist = []
dottargetlist = []
scriptinstall = []
@@ -455,17 +457,26 @@
if f.endswith('.ttf'):
continue
- dotblendlist.append(os.path.join(dp, f))
- if env['WITH_BF_FHS']: dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[2:])) # skip bin/.blender
- else: dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[1:])) # skip bin
-
- dottargetlist.append(dir + os.sep + f)
+ if 'locale' in dp:
+ datafileslist.append(os.path.join(dp,f))
+ if env['WITH_BF_FHS']: dir= os.path.join(*([BLENDERPATH] + ['datafiles'] + dp.split(os.sep)[2:])) # skip bin/.blender
+ else: dir= os.path.join(*([BLENDERPATH] + ['.blender'] + ['datafiles'] + dp.split(os.sep)[1:])) # skip bin
+ datafilestargetlist.append(dir + os.sep + f)
+
+ else:
+ dotblendlist.append(os.path.join(dp, f))
+ if env['WITH_BF_FHS']: dir= os.path.join(*([BLENDERPATH] + ['config'] + dp.split(os.sep)[2:])) # skip bin/.blender
+ else: dir= os.path.join(*([BLENDERPATH] + ['.blender'] + ['config'] + dp.split(os.sep)[1:])) # skip bin
-
+ dottargetlist.append(dir + os.sep + f)
+
dotblenderinstall = []
for targetdir,srcfile in zip(dottargetlist, dotblendlist):
td, tf = os.path.split(targetdir)
dotblenderinstall.append(env.Install(dir=td, source=srcfile))
+ for targetdir,srcfile in zip(datafilestargetlist, datafileslist):
+ td, tf = os.path.split(targetdir)
+ dotblenderinstall.append(env.Install(dir=td, source=srcfile))
if env['WITH_BF_PYTHON']:
#-- .blender/scripts

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
40/b8/48be56c3ee8d3d2afe33320bbb5a

Event Timeline