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:
authorCampbell Barton <ideasman42@gmail.com>2011-10-21 06:13:36 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-21 06:13:36 +0400
commitef218c75edf975b2f3946bd16194cc9679dd2d31 (patch)
treeebe5b13ae6b11fb126c4143fecf3ed46ce5ad827 /source/blender
parent9ec0ea91f02b312ecce8c7b6754db54ce9ba8a1a (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')
-rw-r--r--source/blender/blenkernel/intern/pointcache.c2
-rw-r--r--source/blender/blenlib/BLI_path_util.h2
-rw-r--r--source/blender/blenlib/intern/bpath.c2
-rw-r--r--source/blender/blenlib/intern/path_util.c23
-rw-r--r--source/blender/blenlib/intern/winstuff.c2
-rw-r--r--source/blender/blenloader/intern/writefile.c4
-rw-r--r--source/blender/collada/DocumentImporter.cpp2
-rw-r--r--source/blender/collada/ImageExporter.cpp2
-rw-r--r--source/blender/editors/space_file/filesel.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c2
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c2
11 files changed, 25 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 8e5452e2704..bd5e5dc6049 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -910,7 +910,7 @@ static int ptcache_path(PTCacheID *pid, char *filename)
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 */
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index 4f7f7b482b5..9ccdc37c353 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -104,6 +104,8 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir,
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);
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;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 6e9e3da3b42..c4f6e25f40b 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2678,8 +2678,8 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
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);
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 056d74aabfb..c06867ca107 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -884,7 +884,7 @@ bool DocumentImporter::writeImage( const COLLADAFW::Image* image )
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) {
diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp
index 53c43677c18..6c7251016c3 100644
--- a/source/blender/collada/ImageExporter.cpp
+++ b/source/blender/collada/ImageExporter.cpp
@@ -97,7 +97,7 @@ void ImagesExporter::operator()(Material *ma, Object *ob)
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);
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index f36145aaba0..149d84b86cd 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -613,7 +613,7 @@ void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v))
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);
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 7e4d02036ef..2b78bc3c190 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -321,7 +321,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
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);
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index 9d72eeacf3e..3c2b771ae86 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -540,7 +540,7 @@ static int rna_Sequence_input_count_get(PointerRNA *ptr)
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)