From fa6beb43028b26424cf8aa0712f8f1a9ed8360a4 Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Sat, 27 Feb 2010 17:03:46 +0000 Subject: System dependent standard directory retrieval functions update : return const strings (as coded in libc) instead of malloc'ed buffers and plug them into wip BLI_bfile.c to replace the hardcoded paths --- source/blender/blenlib/CMakeLists.txt | 2 +- source/blender/blenlib/SConscript | 2 +- source/blender/blenlib/intern/BLI_bfile.c | 30 ++++++++++++++---------------- source/blender/blenlib/intern/Makefile | 2 ++ 4 files changed, 18 insertions(+), 18 deletions(-) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index b534087f32c..fec5f1803eb 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -28,7 +28,7 @@ FILE(GLOB SRC intern/*.c) SET(INC . ../makesdna ../blenkernel ../../../intern/guardedalloc ../include - ../gpu + ../gpu ../../../intern/ghost ${FREETYPE_INCLUDE_DIRS} ${ZLIB_INC} ) diff --git a/source/blender/blenlib/SConscript b/source/blender/blenlib/SConscript index df1a096cb99..090094a834d 100644 --- a/source/blender/blenlib/SConscript +++ b/source/blender/blenlib/SConscript @@ -4,7 +4,7 @@ Import ('env') sources = env.Glob('intern/*.c') cflags='' -incs = '. ../makesdna ../blenkernel #/intern/guardedalloc ../editors/include ../gpu' +incs = '. ../makesdna ../blenkernel #/intern/guardedalloc #/intern/ghost ../editors/include ../gpu' incs += ' ' + env['BF_FREETYPE_INC'] incs += ' ' + env['BF_ZLIB_INC'] defs = '' diff --git a/source/blender/blenlib/intern/BLI_bfile.c b/source/blender/blenlib/intern/BLI_bfile.c index 9540b16d2f4..3306283ad3f 100644 --- a/source/blender/blenlib/intern/BLI_bfile.c +++ b/source/blender/blenlib/intern/BLI_bfile.c @@ -46,6 +46,8 @@ #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) @@ -54,6 +56,11 @@ #define BCF_AT_END (1<<3) #define BCF_DISCARD (1<<4) +/* Standard files names */ +#define LAST_SESSION_FILE "last-session" +#define ENVIRONMENT_FILE "environment" + + /* Declaration of internal functions */ void chomp(char* line); void expand_envvars(char* src, char* dst); @@ -221,19 +228,6 @@ void BLI_bfile_set_error(BFILE *bfile, int error) { } -#if defined(WIN32) - #define LAST_SESSION_FILE "%HOME%\\Blender\\last-session FIXME FIXME FIXME" - #define ENVIRONMENT_FILE "FIXME" - #define SHARED_DIRECTORY "FIXME TOO" -#elif defined(OSX) - #define LAST_SESSION_FILE "${HOME}/Library/Application Support/Blender/last-session" - #define ENVIRONMENT_FILE "${HOME}/Library/Application Support/Blender/${BLENDER_VERSION}/environment" - #define SHARED_DIRECTORY "/Library/Application Support/Blender" -#else - #define LAST_SESSION_FILE "${HOME}/.blender/last-session" - #define ENVIRONMENT_FILE "${HOME}/.blender/${BLENDER_VERSION}/environment" - #define SHARED_DIRECTORY "/usr/share/blender" -#endif void BLI_bfile_init_vars() { char file[MAXPATHLEN]; char temp[MAXPATHLEN]; @@ -249,10 +243,12 @@ void BLI_bfile_init_vars() { if(BLI_exist(temp)) { BLI_setenv_if_new("BLENDER_SHARE", dirname(bprogname)); } else { - BLI_setenv_if_new("BLENDER_SHARE", SHARED_DIRECTORY); + BLI_setenv_if_new("BLENDER_SHARE", (const char*)GHOST_getSystemDir()); } - expand_envvars(LAST_SESSION_FILE, file); + 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)) { @@ -283,7 +279,9 @@ void BLI_bfile_init_vars() { } /* Load vars from user and system files */ - expand_envvars(ENVIRONMENT_FILE, file); + 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); diff --git a/source/blender/blenlib/intern/Makefile b/source/blender/blenlib/intern/Makefile index d8aed3ac0ed..130f025d31b 100644 --- a/source/blender/blenlib/intern/Makefile +++ b/source/blender/blenlib/intern/Makefile @@ -52,6 +52,8 @@ CPPFLAGS += -I$(NAN_ZLIB)/include CPPFLAGS += -I../../gpu +CPPFLAGS += -I../../../intern/ghost + ifdef NAN_PTHREADS CPPFLAGS += -I$(NAN_PTHREADS)/include endif -- cgit v1.2.3