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>2013-03-05 10:26:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-03-05 10:26:10 +0400
commit384948908afd5567d6c730a8045a368e8c08e436 (patch)
tree5fd9e156242aedd9271a8d54ed02b5dc9149fb44
parent34233e7fd661dbd378c4e11a1e0d29ed639fbffa (diff)
patch [#34103] path_util_split_dirstring.patch, path_util_split_dirstring_2.patch, path_util_split_dirstring_3.patch
from Lawrence D'Oliveiro (ldo) Get rid of BLI_splitdirstring, replace with calls to BLI_split_dirfile, BLI_split_dir_part and BLI_split_file_part as appropriate.
-rw-r--r--source/blender/blenkernel/intern/font.c6
-rw-r--r--source/blender/blenkernel/intern/packedFile.c13
-rw-r--r--source/blender/blenkernel/intern/texture.c3
-rw-r--r--source/blender/blenlib/BLI_path_util.h1
-rw-r--r--source/blender/blenlib/intern/fileops.c2
-rw-r--r--source/blender/blenlib/intern/path_util.c30
-rw-r--r--source/blender/blenlib/intern/storage.c2
-rw-r--r--source/blender/blenloader/intern/readfile.c16
-rw-r--r--source/blender/editors/physics/physics_fluid.c5
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c7
-rw-r--r--source/blender/editors/space_image/image_ops.c8
-rw-r--r--source/blender/editors/util/ed_util.c3
-rw-r--r--source/blender/imbuf/intern/indexer.c15
-rw-r--r--source/blender/render/intern/source/render_result.c6
14 files changed, 33 insertions, 84 deletions
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 3e1e55132d8..e4170a37102 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -195,11 +195,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *name)
is_builtin = TRUE;
}
else {
- char dir[FILE_MAXDIR];
-
- BLI_strncpy(dir, name, sizeof(dir));
- BLI_splitdirstring(dir, filename);
-
+ BLI_split_file_part(name, filename, sizeof(filename));
pf = newPackedFile(NULL, name, bmain->name);
temp_pf = newPackedFile(NULL, name, bmain->name);
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index cd3357a9281..ec13e58d4e0 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -488,11 +488,8 @@ int unpackVFont(ReportList *reports, VFont *vfont, int how)
int ret_value = RET_ERROR;
if (vfont != NULL) {
- BLI_strncpy(localname, vfont->name, sizeof(localname));
- BLI_splitdirstring(localname, fi);
-
+ BLI_split_file_part(vfont->name, fi, sizeof(fi));
BLI_snprintf(localname, sizeof(localname), "//fonts/%s", fi);
-
newname = unpackFile(reports, vfont->name, localname, vfont->packedfile, how);
if (newname != NULL) {
ret_value = RET_OK;
@@ -513,10 +510,8 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how)
int ret_value = RET_ERROR;
if (sound != NULL) {
- BLI_strncpy(localname, sound->name, sizeof(localname));
- BLI_splitdirstring(localname, fi);
+ BLI_split_file_part(sound->name, fi, sizeof(fi));
BLI_snprintf(localname, sizeof(localname), "//sounds/%s", fi);
-
newname = unpackFile(reports, sound->name, localname, sound->packedfile, how);
if (newname != NULL) {
BLI_strncpy(sound->name, newname, sizeof(sound->name));
@@ -541,10 +536,8 @@ int unpackImage(ReportList *reports, Image *ima, int how)
int ret_value = RET_ERROR;
if (ima != NULL && ima->name[0]) {
- BLI_strncpy(localname, ima->name, sizeof(localname));
- BLI_splitdirstring(localname, fi);
+ BLI_split_file_part(ima->name, fi, sizeof(fi));
BLI_snprintf(localname, sizeof(localname), "//textures/%s", fi);
-
newname = unpackFile(reports, ima->name, localname, ima->packedfile, how);
if (newname != NULL) {
ret_value = RET_OK;
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 2ae76ea6d1c..665e3cb4941 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -911,8 +911,7 @@ void autotexname(Tex *tex)
else if (tex->type == TEX_IMAGE) {
ima = tex->ima;
if (ima) {
- BLI_strncpy(di, ima->name, sizeof(di));
- BLI_splitdirstring(di, fi);
+ BLI_split_file_part(ima->name, fi, sizeof(fi));
strcpy(di, "I.");
strcat(di, fi);
new_id(&bmain->tex, (ID *)tex, di);
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index 92c68dee24d..20fc489cbc3 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -118,7 +118,6 @@ void BLI_newname(char *name, int add);
int BLI_stringdec(const char *string, char *head, char *start, unsigned short *numlen);
void BLI_stringenc(char *string, const char *head, const char *tail, unsigned short numlen, int pic);
int BLI_split_name_num(char *left, int *nr, const char *name, char delim);
-void BLI_splitdirstring(char *di, char *fi);
/* make sure path separators conform to system one */
void BLI_clean(char *path)
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index 3f8b21103b8..937fdf5f787 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -176,7 +176,7 @@ bool BLI_file_is_writable(const char *filename)
else {
/* file doesn't exist -- check I can create it in parent directory */
char parent[FILE_MAX];
- BLI_split_dirfile(filename, parent, NULL, sizeof parent, 0);
+ BLI_split_dirfile(filename, parent, NULL, sizeof(parent), 0);
writable = access(parent, X_OK | W_OK) == 0;
}
return writable;
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 045572ca69d..913a664b97f 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -867,23 +867,6 @@ bool BLI_path_cwd(char *path)
return wasrelative;
}
-
-/* 'di's filename component is moved into 'fi', di is made a dir path */
-/* FIXME: duplicates functionality of BLI_split_dirfile. */
-void BLI_splitdirstring(char *di, char *fi)
-{
- char *lslash = (char *)BLI_last_slash(di);
-
- if (lslash) {
- BLI_strncpy(fi, lslash + 1, FILE_MAXFILE);
- *(lslash + 1) = 0;
- }
- else {
- BLI_strncpy(fi, di, FILE_MAXFILE);
- di[0] = 0;
- }
-}
-
/**
* Copies into *last the part of *dir following the second-last slash.
*/
@@ -1433,15 +1416,12 @@ void BLI_make_exist(char *dir)
*/
void BLI_make_existing_file(const char *name)
{
- char di[FILE_MAX], fi[FILE_MAXFILE];
+ char di[FILE_MAX];
BLI_strncpy(di, name, sizeof(di));
- /* FIXME: use BLI_split_dir_part instead and get rid of fi. */
- BLI_splitdirstring(di, fi);
-
- /* test exist */
- if (BLI_exists(di) == 0) {
- BLI_dir_create_recursive(di);
- }
+ BLI_split_dir_part(name, di, sizeof(di));
+
+ /* make if if the dir doesn't exist */
+ BLI_dir_create_recursive(di);
}
/**
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 9263c250944..22558fca1c5 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -272,7 +272,7 @@ static void bli_builddir(const char *dirname, const char *relname,
memset(file, 0, sizeof(struct direntry));
file->relname = dlink->name;
file->path = BLI_strdupcat(dirname, dlink->name);
- BLI_join_dirfile(fullname, sizeof fullname, dirname, dlink->name);
+ BLI_join_dirfile(fullname, sizeof(fullname), dirname, dlink->name);
// use 64 bit file size, only needed for WIN32 and WIN64.
// Excluding other than current MSVC compiler until able to test
#ifdef WIN32
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 78ae5b00466..a99bdda6b8d 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -493,16 +493,6 @@ void blo_split_main(ListBase *mainlist, Main *main)
split_libdata(lbarray[i], main->next);
}
-/* removes things like /blah/blah/../../blah/ etc, then writes in *name the full path */
-static void cleanup_path(const char *relabase, char *name)
-{
- char filename[FILE_MAXFILE];
-
- BLI_splitdirstring(name, filename);
- BLI_cleanup_dir(relabase, name);
- strcat(name, filename);
-}
-
static void read_file_version(FileData *fd, Main *main)
{
BHead *bhead;
@@ -531,7 +521,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
char name1[FILE_MAX];
BLI_strncpy(name1, filepath, sizeof(name1));
- cleanup_path(relabase, name1);
+ BLI_cleanup_path(relabase, name1);
// printf("blo_find_main: relabase %s\n", relabase);
// printf("blo_find_main: original in %s\n", filepath);
@@ -6256,7 +6246,7 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
}
/* make sure we have full path in lib->filepath */
BLI_strncpy(lib->filepath, lib->name, sizeof(lib->name));
- cleanup_path(fd->relabase, lib->filepath);
+ BLI_cleanup_path(fd->relabase, lib->filepath);
// printf("direct_link_library: name %s\n", lib->name);
// printf("direct_link_library: filepath %s\n", lib->filepath);
@@ -10440,7 +10430,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
if (scanf("%s", newlib_path) > 0) {
BLI_strncpy(mainptr->curlib->name, newlib_path, sizeof(mainptr->curlib->name));
BLI_strncpy(mainptr->curlib->filepath, newlib_path, sizeof(mainptr->curlib->filepath));
- cleanup_path(G.main->name, mainptr->curlib->filepath);
+ BLI_cleanup_path(G.main->name, mainptr->curlib->filepath);
fd = blo_openblenderfile(mainptr->curlib->filepath, basefd->reports);
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 714b1be36a7..bf81db3f3a0 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -683,14 +683,11 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF
}
if (targetDir[0] == '\0' || (!dirExist)) {
- char blendDir[FILE_MAX];
char blendFile[FILE_MAX];
// invalid dir, reset to current/previous
- BLI_strncpy(blendDir, G.main->name, FILE_MAX);
- BLI_splitdirstring(blendDir, blendFile);
+ BLI_split_file_part(G.main->name, blendFile, sizeof(blendFile));
BLI_replace_extension(blendFile, FILE_MAX, ""); /* strip .blend */
-
BLI_snprintf(newSurfdataPath, FILE_MAX, "//fluidsimdata/%s_%s_", blendFile, fsDomain->id.name);
BLI_snprintf(debugStrBuffer, 256, "fluidsimBake::error - warning resetting output dir to '%s'\n", newSurfdataPath);
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index 812ea8c7597..bd53a8e41c5 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -113,7 +113,6 @@ static int file_browse_exec(bContext *C, wmOperator *op)
/* add slash for directories, important for some properties */
if (RNA_property_subtype(fbo->prop) == PROP_DIRPATH) {
- char name[FILE_MAX];
int is_relative = RNA_boolean_get(op->ptr, "relative_path");
id = fbo->ptr.id.data;
@@ -132,8 +131,10 @@ static int file_browse_exec(bContext *C, wmOperator *op)
}
BLI_add_slash(str);
}
- else
- BLI_splitdirstring(str, name);
+ else {
+ char * const lslash = (char *)BLI_last_slash(str);
+ if (lslash) lslash[1] = '\0';
+ }
}
RNA_property_string_set(&fbo->ptr, fbo->prop, str);
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 55f632412ee..46acd2519c2 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1603,7 +1603,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
SpaceImage *sima = CTX_wm_space_image(C);
ImBuf *ibuf;
int tot = 0;
- char di[FILE_MAX], fi[FILE_MAX];
+ char di[FILE_MAX];
if (sima->image == NULL)
return OPERATOR_CANCELLED;
@@ -1632,10 +1632,8 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
for (ibuf = sima->image->ibufs.first; ibuf; ibuf = ibuf->next)
if (ibuf->userflags & IB_BITMAPDIRTY)
break;
-
- BLI_strncpy(di, ibuf->name, FILE_MAX);
- BLI_splitdirstring(di, fi);
-
+
+ BLI_split_dir_part(ibuf->name, di, sizeof(di));
BKE_reportf(op->reports, RPT_INFO, "%d image(s) will be saved in %s", tot, di);
for (ibuf = sima->image->ibufs.first; ibuf; ibuf = ibuf->next) {
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index f0f31b1e793..73062c57526 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -187,8 +187,7 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
if (G.relbase_valid) {
char local_name[FILE_MAXDIR + FILE_MAX], fi[FILE_MAX];
- BLI_strncpy(local_name, abs_name, sizeof(local_name));
- BLI_splitdirstring(local_name, fi);
+ BLI_split_file_part(abs_name, fi, sizeof(fi));
BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi);
if (strcmp(abs_name, local_name) != 0) {
switch (checkPackedFile(local_name, pf)) {
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index 56e5be7c12a..33b2fb6d386 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -361,17 +361,16 @@ int IMB_timecode_to_array_index(IMB_Timecode_Type tc)
* - rebuild helper functions
* ---------------------------------------------------------------------- */
-static void get_index_dir(struct anim *anim, char *index_dir)
+static void get_index_dir(struct anim *anim, char *index_dir, size_t index_dir_len)
{
if (!anim->index_dir[0]) {
char fname[FILE_MAXFILE];
- BLI_strncpy(index_dir, anim->name, FILE_MAXDIR);
- BLI_splitdirstring(index_dir, fname);
- BLI_join_dirfile(index_dir, FILE_MAXDIR, index_dir, "BL_proxy");
- BLI_join_dirfile(index_dir, FILE_MAXDIR, index_dir, fname);
+ BLI_split_dirfile(anim->name, index_dir, fname, index_dir_len, sizeof(fname));
+ BLI_join_dirfile(index_dir, index_dir_len, index_dir, "BL_proxy");
+ BLI_join_dirfile(index_dir, index_dir_len, index_dir, fname);
}
else {
- BLI_strncpy(index_dir, anim->index_dir, FILE_MAXDIR);
+ BLI_strncpy(index_dir, anim->index_dir, index_dir_len);
}
}
@@ -396,7 +395,7 @@ static void get_proxy_filename(struct anim *anim, IMB_Proxy_Size preview_size,
BLI_snprintf(proxy_temp_name, sizeof(proxy_temp_name), "proxy_%d%s_part.avi",
(int) (proxy_fac[i] * 100), stream_suffix);
- get_index_dir(anim, index_dir);
+ get_index_dir(anim, index_dir, sizeof(index_dir));
BLI_join_dirfile(fname, FILE_MAXFILE + FILE_MAXDIR, index_dir,
temp ? proxy_temp_name : proxy_name);
@@ -425,7 +424,7 @@ static void get_tc_filename(struct anim *anim, IMB_Timecode_Type tc,
BLI_snprintf(index_name, 256, index_names[i], stream_suffix);
- get_index_dir(anim, index_dir);
+ get_index_dir(anim, index_dir, sizeof(index_dir));
BLI_join_dirfile(fname, FILE_MAXFILE + FILE_MAXDIR,
index_dir, index_name);
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index ec926c3b649..ab0f16c8c2a 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -983,11 +983,9 @@ void render_result_exr_file_merge(RenderResult *rr, RenderResult *rrpart)
/* path to temporary exr file */
void render_result_exr_file_path(Scene *scene, const char *layname, int sample, char *filepath)
{
- char di[FILE_MAX], name[FILE_MAXFILE + MAX_ID_NAME + MAX_ID_NAME + 100], fi[FILE_MAXFILE];
-
- BLI_strncpy(di, G.main->name, FILE_MAX);
- BLI_splitdirstring(di, fi);
+ char name[FILE_MAXFILE + MAX_ID_NAME + MAX_ID_NAME + 100], fi[FILE_MAXFILE];
+ BLI_split_file_part(G.main->name, fi, sizeof(fi));
if (sample == 0)
BLI_snprintf(name, sizeof(name), "%s_%s_%s.exr", fi, scene->id.name + 2, layname);
else