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>2008-04-26 17:08:57 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-04-26 17:08:57 +0400
commitc8376869b1a521c903a6f8d1be49e48c2966df70 (patch)
tree6e3ff79d8b57303d5ea70a8211af78618cf40a78 /source/blender
parent19985ae918759780d3cf607a87b9fd110be518a0 (diff)
BLI_split_dirfile was being used in cases it should not have been,
Added BLI_split_dirfile_basic, that only splits the path into directory and file. without checking the dir exists or creating it, without changing the original string that is passed to it.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/pointcache.c2
-rw-r--r--source/blender/blenkernel/intern/text.c6
-rw-r--r--source/blender/blenlib/BLI_blenlib.h1
-rw-r--r--source/blender/blenlib/intern/bpath.c21
-rw-r--r--source/blender/blenlib/intern/util.c35
-rw-r--r--source/blender/python/BPY_interface.c2
-rw-r--r--source/blender/src/editscreen.c2
-rw-r--r--source/blender/src/usiblender.c2
8 files changed, 44 insertions, 27 deletions
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 8407dd2b7c3..fdaeedf7e38 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -177,7 +177,7 @@ static int ptcache_path(PTCacheID *pid, char *filename)
blendfilename= (lib)? lib->filename: G.sce;
- BLI_split_dirfile(blendfilename, dir, file);
+ BLI_split_dirfile_basic(blendfilename, NULL, file);
i = strlen(file);
/* remove .blend */
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 23c3a1eacb6..b6552be93a9 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -212,7 +212,6 @@ int reopen_text(Text *text)
int i, llen, len;
unsigned char *buffer;
TextLine *tmp;
- char sdir[FILE_MAXDIR];
char sfile[FILE_MAXFILE];
char str[FILE_MAXDIR+FILE_MAXFILE];
@@ -220,7 +219,7 @@ int reopen_text(Text *text)
BLI_strncpy(str, text->name, FILE_MAXDIR+FILE_MAXFILE);
BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
- BLI_split_dirfile(str, sdir, sfile);
+ BLI_split_dirfile_basic(str, NULL, sfile);
fp= fopen(str, "r");
if(fp==NULL) return 0;
@@ -312,14 +311,13 @@ Text *add_text(char *file)
unsigned char *buffer;
TextLine *tmp;
Text *ta;
- char sdir[FILE_MAXDIR];
char sfile[FILE_MAXFILE];
char str[FILE_MAXDIR+FILE_MAXFILE];
BLI_strncpy(str, file, FILE_MAXDIR+FILE_MAXFILE);
if (G.scene) /* can be NULL (bg mode) */
BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
- BLI_split_dirfile(str, sdir, sfile);
+ BLI_split_dirfile_basic(str, NULL, sfile);
fp= fopen(str, "r");
if(fp==NULL) return NULL;
diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h
index 6c0e42fe42a..33567d92c99 100644
--- a/source/blender/blenlib/BLI_blenlib.h
+++ b/source/blender/blenlib/BLI_blenlib.h
@@ -96,6 +96,7 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir,
void BLI_make_exist(char *dir);
void BLI_make_existing_file(char *name);
void BLI_split_dirfile(char *string, char *dir, char *file);
+void BLI_split_dirfile_basic(const char *string, char *dir, char *file);
void BLI_join_dirfile(char *string, const char *dir, const char *file);
int BLI_testextensie(const char *str, const char *ext);
void addlisttolist(ListBase *list1, ListBase *list2);
diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c
index 4e4b47b2c92..05e8b08f2d1 100644
--- a/source/blender/blenlib/intern/bpath.c
+++ b/source/blender/blenlib/intern/bpath.c
@@ -259,22 +259,7 @@ void seq_setpath(struct BPathIterator *bpi, char *path) {
if (SEQ_HAS_PATH(seq)) {
if (seq->type == SEQ_IMAGE || seq->type == SEQ_MOVIE) {
-
- int lslash, i = 0;
- for (i=0; path[i]!='\0'; i++) {
- if (path[i]=='\\' || path[i]=='/')
- lslash = i+1;
- }
-
- if (lslash) {
- BLI_strncpy( seq->strip->dir, path, lslash+1); /* +1 to include the slash and the last char */
- } else {
- path[0] = '\0';
- }
-
- if (seq->strip->stripdata) { /* should always be true! */
- BLI_strncpy( seq->strip->stripdata->name, path+lslash, sizeof(seq->strip->stripdata->name));
- }
+ BLI_split_dirfile_basic(path, seq->strip->dir, seq->strip->stripdata->name);
} else {
/* simple case */
BLI_strncpy(seq->strip->dir, path, sizeof(seq->strip->dir));
@@ -657,7 +642,7 @@ void findMissingFiles(char *str) {
waitcursor( 1 );
- BLI_split_dirfile(str, dirname, dummyname);
+ BLI_split_dirfile_basic(str, dirname, NULL);
BLI_bpathIterator_init(&bpi);
@@ -678,7 +663,7 @@ void findMissingFiles(char *str) {
/* can the dir be opened? */
filesize = -1;
recur_depth = 0;
- BLI_split_dirfile(filepath, dummyname, filename); /* the file to find */
+ BLI_split_dirfile_basic(filepath, NULL, filename); /* the file to find */
findFileRecursive(filename_new, dirname, filename, &filesize, &recur_depth);
if (filesize == -1) { /* could not open dir */
diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c
index 623389a6ba2..c79f1b56f1d 100644
--- a/source/blender/blenlib/intern/util.c
+++ b/source/blender/blenlib/intern/util.c
@@ -1426,8 +1426,41 @@ int BLI_testextensie(const char *str, const char *ext)
return (retval);
}
+/*
+ * This is a simple version of BLI_split_dirfile that has the following advantages...
+ *
+ * Converts "/foo/bar.txt" to "/foo/" and "bar.txt"
+ * - wont change 'string'
+ * - wont create any directories
+ * - dosnt use CWD, or deal with relative paths.
+ * - Only fill's in *dir and *file when they are non NULL
+ * */
+void BLI_split_dirfile_basic(const char *string, char *dir, char *file)
+{
+ int lslash=0, i = 0;
+ for (i=0; string[i]!='\0'; i++) {
+ if (string[i]=='\\' || string[i]=='/')
+ lslash = i+1;
+ }
+ if (dir) {
+ if (lslash) {
+ BLI_strncpy( dir, string, lslash+1); /* +1 to include the slash and the last char */
+ } else {
+ dir[0] = '\0';
+ }
+ }
+
+ if (file) {
+ strcpy( file, string+lslash);
+ }
+}
+
-/* warning, can modify 'string' */
+/* Warning,
+ * - May modify 'string' variable
+ * - May create the directory if it dosnt exist
+ * if this is not needed use BLI_split_dirfile_basic(...)
+ */
void BLI_split_dirfile(char *string, char *dir, char *file)
{
int a;
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index 9d1d0e0f7d6..5858b933562 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -796,7 +796,7 @@ int BPY_run_script(Script *script)
if (bpyhome) {
BLI_strncpy(ftmp, script->scriptname, sizeof(ftmp));
- BLI_split_dirfile(ftmp, fpath, fname); /* get the filename only - fname */
+ BLI_split_dirfile_basic(ftmp, NULL, fname); /* get the filename only - fname */
BLI_strncpy(fpath, bpy_gethome(1), sizeof(fpath));
BLI_add_slash(fpath);
strcat(fpath, fname);
diff --git a/source/blender/src/editscreen.c b/source/blender/src/editscreen.c
index 58c3c6e1267..2df92af5bca 100644
--- a/source/blender/src/editscreen.c
+++ b/source/blender/src/editscreen.c
@@ -1589,7 +1589,7 @@ void mainwindow_set_filename_to_title(char *filename)
char dir[FILE_MAXDIR];
char file[FILE_MAXFILE];
- BLI_split_dirfile(filename, dir, file);
+ BLI_split_dirfile_basic(filename, dir, file);
if(BLI_streq(file, ".B.blend") || filename[0] =='\0')
sprintf(str, "Blender");
diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c
index dfcfc0d57f7..8d6bf830dbf 100644
--- a/source/blender/src/usiblender.c
+++ b/source/blender/src/usiblender.c
@@ -786,7 +786,7 @@ static void readBlog(void)
fsmenu_append_separator();
/* add last saved file */
- BLI_split_dirfile(G.sce, name, filename); /* G.sce shouldn't be relative */
+ BLI_split_dirfile_basic(G.sce, name, filename); /* G.sce shouldn't be relative */
fsmenu_insert_entry(name, 0, 0);