[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41166] trunk/blender/source: - add convenience functions BLI_split_dir_part / BLI_split_file_part, which just call BLI_split_dirfile().
Campbell Barton
ideasman42 at gmail.com
Fri Oct 21 04:13:37 CEST 2011
Revision: 41166
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41166
Author: campbellbarton
Date: 2011-10-21 02:13:36 +0000 (Fri, 21 Oct 2011)
Log Message:
-----------
- 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.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/pointcache.c
trunk/blender/source/blender/blenlib/BLI_path_util.h
trunk/blender/source/blender/blenlib/intern/bpath.c
trunk/blender/source/blender/blenlib/intern/path_util.c
trunk/blender/source/blender/blenlib/intern/winstuff.c
trunk/blender/source/blender/blenloader/intern/writefile.c
trunk/blender/source/blender/collada/DocumentImporter.cpp
trunk/blender/source/blender/collada/ImageExporter.cpp
trunk/blender/source/blender/editors/space_file/filesel.c
trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c
trunk/blender/source/blender/makesrna/intern/rna_sequencer.c
trunk/blender/source/creator/creator.c
trunk/blender/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
Modified: trunk/blender/source/blender/blenkernel/intern/pointcache.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pointcache.c 2011-10-21 01:46:03 UTC (rev 41165)
+++ trunk/blender/source/blender/blenkernel/intern/pointcache.c 2011-10-21 02:13:36 UTC (rev 41166)
@@ -910,7 +910,7 @@
else if (G.relbase_valid || lib) {
char file[MAX_PTCACHE_PATH]; /* we dont want the dir, only the file */
- BLI_split_dirfile(blendfilename, NULL, file, 0, sizeof(file));
+ BLI_split_file_part(blendfilename, file, sizeof(file));
i = strlen(file);
/* remove .blend */
Modified: trunk/blender/source/blender/blenlib/BLI_path_util.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_path_util.h 2011-10-21 01:46:03 UTC (rev 41165)
+++ trunk/blender/source/blender/blenlib/BLI_path_util.h 2011-10-21 02:13:36 UTC (rev 41166)
@@ -104,6 +104,8 @@
void BLI_make_exist(char *dir);
void BLI_make_existing_file(const char *name);
void BLI_split_dirfile(const char *string, char *dir, char *file, const size_t dirlen, const size_t filelen);
+void BLI_split_dir_part(const char *string, char *dir, const size_t dirlen);
+void BLI_split_file_part(const char *string, char *file, const size_t filelen);
void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *file);
char *BLI_path_basename(char *path);
int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir);
Modified: trunk/blender/source/blender/blenlib/intern/bpath.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/bpath.c 2011-10-21 01:46:03 UTC (rev 41165)
+++ trunk/blender/source/blender/blenlib/intern/bpath.c 2011-10-21 02:13:36 UTC (rev 41166)
@@ -903,7 +903,7 @@
//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);
Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c 2011-10-21 01:46:03 UTC (rev 41165)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c 2011-10-21 02:13:36 UTC (rev 41166)
@@ -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 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 @@
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,11 +960,7 @@
* 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) {
BLI_join_dirfile(relfolder, sizeof(relfolder), folder_name, subfolder_name);
@@ -1430,6 +1423,16 @@
}
}
+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 @@
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;
Modified: trunk/blender/source/blender/blenlib/intern/winstuff.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/winstuff.c 2011-10-21 01:46:03 UTC (rev 41165)
+++ trunk/blender/source/blender/blenlib/intern/winstuff.c 2011-10-21 02:13:36 UTC (rev 41166)
@@ -56,7 +56,7 @@
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;
Modified: trunk/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/writefile.c 2011-10-21 01:46:03 UTC (rev 41165)
+++ trunk/blender/source/blender/blenloader/intern/writefile.c 2011-10-21 02:13:36 UTC (rev 41166)
@@ -2678,8 +2678,8 @@
if(write_flags & G_FILE_RELATIVE_REMAP) {
char dir1[FILE_MAXDIR+FILE_MAXFILE];
char dir2[FILE_MAXDIR+FILE_MAXFILE];
- BLI_split_dirfile(filepath, dir1, NULL, sizeof(dir1), 0);
- BLI_split_dirfile(mainvar->name, dir2, NULL, sizeof(dir2), 0);
+ BLI_split_dir_part(filepath, dir1, sizeof(dir1));
+ BLI_split_dir_part(mainvar->name, dir2, sizeof(dir2));
/* just incase there is some subtle difference */
BLI_cleanup_dir(mainvar->name, dir1);
Modified: trunk/blender/source/blender/collada/DocumentImporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/DocumentImporter.cpp 2011-10-21 01:46:03 UTC (rev 41165)
+++ trunk/blender/source/blender/collada/DocumentImporter.cpp 2011-10-21 02:13:36 UTC (rev 41166)
@@ -884,7 +884,7 @@
char dir[FILE_MAX];
char full_path[FILE_MAX];
- BLI_split_dirfile(filename, dir, NULL, sizeof(dir), 0);
+ BLI_split_dir_part(filename, dir, sizeof(dir));
BLI_join_dirfile(full_path, sizeof(full_path), dir, filepath.c_str());
Image *ima = BKE_add_image_file(full_path);
if (!ima) {
Modified: trunk/blender/source/blender/collada/ImageExporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/ImageExporter.cpp 2011-10-21 01:46:03 UTC (rev 41165)
+++ trunk/blender/source/blender/collada/ImageExporter.cpp 2011-10-21 02:13:36 UTC (rev 41166)
@@ -97,7 +97,7 @@
char src[FILE_MAX];
char dir[FILE_MAX];
- BLI_split_dirfile(this->export_settings->filepath, dir, NULL, sizeof(dir), 0);
+ BLI_split_dir_part(this->export_settings->filepath, dir, sizeof(dir));
BKE_rebase_path(abs, sizeof(abs), rel, sizeof(rel), G.main->name, image->name, dir);
Modified: trunk/blender/source/blender/editors/space_file/filesel.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/filesel.c 2011-10-21 01:46:03 UTC (rev 41165)
+++ trunk/blender/source/blender/editors/space_file/filesel.c 2011-10-21 02:13:36 UTC (rev 41166)
@@ -613,7 +613,7 @@
DIR *dir;
struct dirent *de;
- BLI_split_dirfile(str, dirname, NULL, sizeof(dirname), 0);
+ BLI_split_dir_part(str, dirname, sizeof(dirname));
dir = opendir(dirname);
Modified: trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c
===================================================================
--- trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c 2011-10-21 01:46:03 UTC (rev 41165)
+++ trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c 2011-10-21 02:13:36 UTC (rev 41166)
@@ -321,7 +321,7 @@
char dir_only[FILE_MAX];
char file_only[FILE_MAX];
- BLI_split_dirfile(seq_load.path, dir_only, NULL, sizeof(dir_only), 0);
+ BLI_split_dir_part(seq_load.path, dir_only, sizeof(dir_only));
RNA_BEGIN(op->ptr, itemptr, "files") {
RNA_string_get(&itemptr, "name", file_only);
Modified: trunk/blender/source/blender/makesrna/intern/rna_sequencer.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_sequencer.c 2011-10-21 01:46:03 UTC (rev 41165)
+++ trunk/blender/source/blender/makesrna/intern/rna_sequencer.c 2011-10-21 02:13:36 UTC (rev 41166)
@@ -540,7 +540,7 @@
static void rna_SequenceElement_filename_set(PointerRNA *ptr, const char *value)
{
StripElem *elem= (StripElem*)(ptr->data);
- BLI_split_dirfile(value, NULL, elem->name, 0, sizeof(elem->name));
+ BLI_split_file_part(value, elem->name, sizeof(elem->name));
}*/
static void rna_Sequence_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c 2011-10-21 01:46:03 UTC (rev 41165)
+++ trunk/blender/source/creator/creator.c 2011-10-21 02:13:36 UTC (rev 41166)
@@ -141,7 +141,8 @@
extern int pluginapi_force_ref(void); /* from blenpluginapi:pluginapi.c */
-char bprogname[FILE_MAX]; /* from blenpluginapi:pluginapi.c */
+char bprogname[FILE_MAX];
+char bprogdir[FILE_MAX];
char btempdir[FILE_MAX];
#define BLEND_VERSION_STRING_FMT "Blender %d.%02d (sub %d)\n", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION
@@ -1157,6 +1158,7 @@
// need this.
BLI_where_am_i(bprogname, sizeof(bprogname), argv[0]);
+ BLI_split_dir_part(bprogname, bprogdir, sizeof(bprogdir));
BLI_threadapi_init();
Modified: trunk/blender/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
===================================================================
--- trunk/blender/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp 2011-10-21 01:46:03 UTC (rev 41165)
+++ trunk/blender/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp 2011-10-21 02:13:36 UTC (rev 41166)
@@ -117,6 +117,7 @@
const int kMinWindowHeight = 100;
char bprogname[FILE_MAX];
+char bprogdir[FILE_MAX];
static void mem_error_cb(const char *errorStr)
{
@@ -380,6 +381,7 @@
#endif /* __alpha__ */
#endif /* __linux__ */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list