diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-10-21 06:13:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-10-21 06:13:36 +0400 |
commit | ef218c75edf975b2f3946bd16194cc9679dd2d31 (patch) | |
tree | ebe5b13ae6b11fb126c4143fecf3ed46ce5ad827 /source/blender/blenlib/intern | |
parent | 9ec0ea91f02b312ecce8c7b6754db54ce9ba8a1a (diff) |
- add convenience functions BLI_split_dir_part / BLI_split_file_part, which just call BLI_split_dirfile().
- add a fixed value for bprogdir (the dir of bprogname), since it was being used for resource lookups.
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/bpath.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 23 | ||||
-rw-r--r-- | source/blender/blenlib/intern/winstuff.c | 2 |
3 files changed, 15 insertions, 12 deletions
diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index 4e4f8b3cade..293f824c5fd 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -903,7 +903,7 @@ void findMissingFiles(Main *bmain, const char *str) //XXX waitcursor( 1 ); - BLI_split_dirfile(str, dirname, NULL, sizeof(dirname), 0); + BLI_split_dir_part(str, dirname, sizeof(dirname)); BLI_bpathIterator_init(&bpi, bmain, bmain->name, 0); diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 21f91ce8f14..b338bfcbc50 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -88,6 +88,7 @@ #define UNIQUE_NAME_MAX 128 extern char bprogname[]; +extern char bprogdir[]; static int add_win32_extension(char *name); static char *blender_version_decimal(const int ver); @@ -875,7 +876,6 @@ static int test_env_path(char *path, const char *envvar) static int get_path_local(char *targetpath, const char *folder_name, const char *subfolder_name, const int ver) { - char bprogdir[FILE_MAX]; char relfolder[FILE_MAX]; #ifdef PATH_DEBUG2 @@ -892,10 +892,7 @@ static int get_path_local(char *targetpath, const char *folder_name, const char else { relfolder[0]= '\0'; } - - /* use argv[0] (bprogname) to get the path to the executable */ - BLI_split_dirfile(bprogname, bprogdir, NULL, sizeof(bprogdir), 0); - + /* try EXECUTABLE_DIR/2.5x/folder_name - new default directory for local blender installed files */ if(test_path(targetpath, bprogdir, blender_version_decimal(ver), relfolder)) return 1; @@ -963,10 +960,6 @@ static int get_path_system(char *targetpath, const char *folder_name, const char * these are only used when running blender from source */ char cwd[FILE_MAX]; char relfolder[FILE_MAX]; - char bprogdir[FILE_MAX]; - - /* use argv[0] (bprogname) to get the path to the executable */ - BLI_split_dirfile(bprogname, bprogdir, NULL, sizeof(bprogdir), 0); if(folder_name) { if (subfolder_name) { @@ -1430,6 +1423,16 @@ void BLI_split_dirfile(const char *string, char *dir, char *file, const size_t d } } +void BLI_split_dir_part(const char *string, char *dir, const size_t dirlen) +{ + BLI_split_dirfile(string, dir, NULL, dirlen, 0); +} + +void BLI_split_file_part(const char *string, char *file, const size_t filelen) +{ + BLI_split_dirfile(string, NULL, file, 0, filelen); +} + /* simple appending of filename to dir, does not check for valid path! */ void BLI_join_dirfile(char *dst, const size_t maxlen, const char *dir, const char *file) { @@ -1516,7 +1519,7 @@ int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const if (rel) rel[0]= 0; - BLI_split_dirfile(base_dir, blend_dir, NULL, sizeof(blend_dir), 0); + BLI_split_dir_part(base_dir, blend_dir, sizeof(blend_dir)); if (src_dir[0]=='\0') return 0; diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 9594197ef90..21ad0ff7253 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -56,7 +56,7 @@ int BLI_getInstallationDir( char * str ) { int a; GetModuleFileName(NULL,str,FILE_MAXDIR+FILE_MAXFILE); - BLI_split_dirfile(str, dir, NULL, sizeof(dir), 0); /* shouldn't be relative */ + BLI_split_dir_part(str, dir, sizeof(dir)); /* shouldn't be relative */ a = strlen(dir); if(dir[a-1] == '\\') dir[a-1]=0; |