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>2020-04-07 05:02:21 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-04-07 05:10:36 +0300
commitd14e76806921f9a4d686ea731364242ededb735d (patch)
tree0d43db74bc544798eca32f1a46deb2705d87a1a3
parentd54757e389862a081deb3d2064e95fdaddb1880a (diff)
Cleanup: BLI_path.h function renaming
Use BLI_path_ prefix, more consistent names: BLI_parent_dir -> BLI_path_parent_dir BLI_parent_dir_until_exists -> BLI_path_parent_dir_until_exists BLI_ensure_filename -> BLI_path_filename_ensure BLI_first_slash -> BLI_path_slash_find BLI_last_slash -> BLI_path_slash_rfind BLI_add_slash -> BLI_path_slash_ensure BLI_del_slash -> BLI_path_slash_rstrip BLI_path_native_slash -> BLI_path_slash_native Rename 'cleanup' to 'normalize', similar to Python's `os.path.normpath`. BLI_cleanup_path -> BLI_path_normalize BLI_cleanup_dir -> BLI_path_normalize_dir BLI_cleanup_unc -> BLI_path_normalize_unc BLI_cleanup_unc16 -> BLI_path_normalize_unc16 Clarify naming for extracting, creating numbered paths: BLI_stringenc -> BLI_path_sequence_encode BLI_stringdec -> BLI_path_sequence_decode Part of T74506 proposal.
-rw-r--r--source/blender/blenkernel/intern/appdir.c10
-rw-r--r--source/blender/blenkernel/intern/blendfile.c4
-rw-r--r--source/blender/blenkernel/intern/bpath.c8
-rw-r--r--source/blender/blenkernel/intern/image.c6
-rw-r--r--source/blender/blenkernel/intern/image_save.c6
-rw-r--r--source/blender/blenkernel/intern/movieclip.c10
-rw-r--r--source/blender/blenkernel/intern/pointcache.c6
-rw-r--r--source/blender/blenkernel/intern/seqcache.c4
-rw-r--r--source/blender/blenlib/BLI_path_util.h26
-rw-r--r--source/blender/blenlib/intern/BLI_filelist.c2
-rw-r--r--source/blender/blenlib/intern/fileops.c26
-rw-r--r--source/blender/blenlib/intern/path_util.c74
-rw-r--r--source/blender/blenloader/intern/readfile.c6
-rw-r--r--source/blender/blenloader/intern/writefile.c4
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c6
-rw-r--r--source/blender/editors/space_clip/clip_buttons.c2
-rw-r--r--source/blender/editors/space_clip/clip_ops.c2
-rw-r--r--source/blender/editors/space_file/file_ops.c32
-rw-r--r--source/blender/editors/space_file/filelist.c18
-rw-r--r--source/blender/editors/space_file/filesel.c4
-rw-r--r--source/blender/editors/space_image/image_buttons.c2
-rw-r--r--source/blender/editors/space_image/image_ops.c3
-rw-r--r--source/blender/editors/space_image/image_sequence.c8
-rw-r--r--source/blender/freestyle/intern/application/Controller.cpp2
-rw-r--r--source/blender/freestyle/intern/system/StringUtils.cpp2
-rw-r--r--source/blender/imbuf/intern/anim_movie.c2
-rw-r--r--source/blender/io/collada/ImageExporter.cpp2
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c2
-rw-r--r--source/blender/windowmanager/intern/wm_files.c4
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c2
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c6
-rw-r--r--tests/gtests/blenlib/BLI_path_util_test.cc18
32 files changed, 156 insertions, 153 deletions
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index 0e578250b39..92b7bdcfb98 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -232,7 +232,7 @@ static bool get_path_local(char *targetpath,
char osx_resourses[FILE_MAX];
BLI_snprintf(osx_resourses, sizeof(osx_resourses), "%s../Resources", bprogdir);
/* Remove the '/../' added above. */
- BLI_cleanup_path(NULL, osx_resourses);
+ BLI_path_normalize(NULL, osx_resourses);
return test_path(
targetpath, targetpath_len, osx_resourses, blender_version_decimal(ver), relfolder);
#else
@@ -692,7 +692,7 @@ static void where_am_i(char *fullname, const size_t maxlen, const char *name)
BLI_path_program_extensions_add_win32(fullname, maxlen);
#endif
}
- else if (BLI_last_slash(name)) {
+ else if (BLI_path_slash_rfind(name)) {
// full path
BLI_strncpy(fullname, name, maxlen);
#ifdef _WIN32
@@ -703,7 +703,7 @@ static void where_am_i(char *fullname, const size_t maxlen, const char *name)
BLI_path_program_search(fullname, maxlen, name);
}
/* Remove "/./" and "/../" so string comparisons can be used on the path. */
- BLI_cleanup_path(NULL, fullname);
+ BLI_path_normalize(NULL, fullname);
#if defined(DEBUG)
if (!STREQ(name, fullname)) {
@@ -939,7 +939,7 @@ static void where_is_temp(char *fullname, char *basename, const size_t maxlen, c
}
else {
/* add a trailing slash if needed */
- BLI_add_slash(fullname);
+ BLI_path_slash_ensure(fullname);
#ifdef WIN32
if (userdir && userdir != fullname) {
/* also set user pref to show %TEMP%. /tmp/ is just plain confusing for Windows users. */
@@ -967,7 +967,7 @@ static void where_is_temp(char *fullname, char *basename, const size_t maxlen, c
if (BLI_is_dir(tmp_name)) {
BLI_strncpy(basename, fullname, maxlen);
BLI_strncpy(fullname, tmp_name, maxlen);
- BLI_add_slash(fullname);
+ BLI_path_slash_ensure(fullname);
}
else {
CLOG_WARN(&LOG,
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index d862132480a..2a53a0b69a4 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -76,7 +76,7 @@
static bool clean_paths_visit_cb(void *UNUSED(userdata), char *path_dst, const char *path_src)
{
strcpy(path_dst, path_src);
- BLI_path_native_slash(path_dst);
+ BLI_path_slash_native(path_dst);
return !STREQ(path_dst, path_src);
}
@@ -88,7 +88,7 @@ static void clean_paths(Main *main)
BKE_bpath_traverse_main(main, clean_paths_visit_cb, BKE_BPATH_TRAVERSE_SKIP_MULTIFILE, NULL);
for (scene = main->scenes.first; scene; scene = scene->id.next) {
- BLI_path_native_slash(scene->r.pic);
+ BLI_path_slash_native(scene->r.pic);
}
}
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index 5891a0361d8..d179bfbedfd 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -137,7 +137,7 @@ static bool bpath_relative_rebase_visit_cb(void *userdata, char *path_dst, const
char filepath[(FILE_MAXDIR * 2) + FILE_MAXFILE];
BLI_strncpy(filepath, path_src, FILE_MAX);
if (BLI_path_abs(filepath, data->basedir_src)) {
- BLI_cleanup_path(NULL, filepath);
+ BLI_path_normalize(NULL, filepath);
/* This may fail, if so it's fine to leave absolute since the path is still valid. */
BLI_path_rel(filepath, data->basedir_dst);
@@ -815,13 +815,13 @@ bool BKE_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *pa
}
/* Make referenced file absolute. This would be a side-effect of
- * BLI_cleanup_path, but we do it explicitly so we know if it changed. */
+ * BLI_path_normalize, but we do it explicitly so we know if it changed. */
BLI_strncpy(filepath, path_src, FILE_MAX);
if (BLI_path_abs(filepath, base_old)) {
/* Path was relative and is now absolute. Remap.
- * Important BLI_cleanup_path runs before the path is made relative
+ * Important BLI_path_normalize runs before the path is made relative
* because it wont work for paths that start with "//../" */
- BLI_cleanup_path(base_new, filepath);
+ BLI_path_normalize(base_new, filepath);
BLI_path_rel(filepath, base_new);
BLI_strncpy(path_dst, filepath, FILE_MAX);
return true;
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index f58e7c06d7f..9bd1a632278 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -5316,8 +5316,8 @@ void BKE_image_user_file_path(ImageUser *iuser, Image *ima, char *filepath)
index = (iuser && iuser->tile) ? iuser->tile : 1001;
}
- BLI_stringdec(filepath, head, tail, &numlen);
- BLI_stringenc(filepath, head, tail, numlen, index);
+ BLI_path_sequence_decode(filepath, head, tail, &numlen);
+ BLI_path_sequence_encode(filepath, head, tail, numlen, index);
}
BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id));
@@ -5458,7 +5458,7 @@ float *BKE_image_get_float_pixels_for_frame(struct Image *image, int frame, int
int BKE_image_sequence_guess_offset(Image *image)
{
- return BLI_stringdec(image->name, NULL, NULL, NULL);
+ return BLI_path_sequence_decode(image->name, NULL, NULL, NULL);
}
bool BKE_image_has_anim(Image *ima)
diff --git a/source/blender/blenkernel/intern/image_save.c b/source/blender/blenkernel/intern/image_save.c
index b2e0f234f1e..c034fe895a6 100644
--- a/source/blender/blenkernel/intern/image_save.c
+++ b/source/blender/blenkernel/intern/image_save.c
@@ -406,7 +406,7 @@ bool BKE_image_save(
if (ima->source == IMA_SRC_TILED) {
/* Verify filepath for tiles images. */
- if (BLI_stringdec(opts->filepath, NULL, NULL, NULL) != 1001) {
+ if (BLI_path_sequence_decode(opts->filepath, NULL, NULL, NULL) != 1001) {
BKE_reportf(reports,
RPT_ERROR,
"When saving a tiled image, the path '%s' must contain the UDIM tag 1001",
@@ -429,7 +429,7 @@ bool BKE_image_save(
char head[FILE_MAX], tail[FILE_MAX];
unsigned short numlen;
- BLI_stringdec(filepath, head, tail, &numlen);
+ BLI_path_sequence_decode(filepath, head, tail, &numlen);
/* Save all other tiles. */
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
@@ -439,7 +439,7 @@ bool BKE_image_save(
}
/* Build filepath of the tile. */
- BLI_stringenc(opts->filepath, head, tail, numlen, tile->tile_number);
+ BLI_path_sequence_encode(opts->filepath, head, tail, numlen, tile->tile_number);
iuser->tile = tile->tile_number;
ok = ok && image_save_single(reports, ima, iuser, opts, &colorspace_changed);
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index ad9314d7ee3..847466915ab 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -197,14 +197,14 @@ static void get_sequence_fname(const MovieClip *clip, const int framenr, char *n
int offset;
BLI_strncpy(name, clip->name, sizeof(clip->name));
- BLI_stringdec(name, head, tail, &numlen);
+ BLI_path_sequence_decode(name, head, tail, &numlen);
/* Movie-clips always points to first image from sequence, auto-guess offset for now.
* Could be something smarter in the future. */
offset = sequence_guess_offset(clip->name, strlen(head), numlen);
if (numlen) {
- BLI_stringenc(
+ BLI_path_sequence_encode(
name, head, tail, numlen, offset + framenr - clip->start_frame + clip->frame_offset);
}
else {
@@ -421,7 +421,7 @@ static void movieclip_calc_length(MovieClip *clip)
unsigned short numlen;
char name[FILE_MAX], head[FILE_MAX], tail[FILE_MAX];
- BLI_stringdec(clip->name, head, tail, &numlen);
+ BLI_path_sequence_decode(clip->name, head, tail, &numlen);
if (numlen == 0) {
/* there's no number group in file name, assume it's single framed sequence */
@@ -505,7 +505,7 @@ static int user_frame_to_cache_frame(MovieClip *clip, int framenr)
unsigned short numlen;
char head[FILE_MAX], tail[FILE_MAX];
- BLI_stringdec(clip->name, head, tail, &numlen);
+ BLI_path_sequence_decode(clip->name, head, tail, &numlen);
/* see comment in get_sequence_fname */
clip->cache->sequence_offset = sequence_guess_offset(clip->name, strlen(head), numlen);
@@ -648,7 +648,7 @@ static bool put_imbuf_cache(
clip->cache->sequence_offset = -1;
if (clip->source == MCLIP_SRC_SEQUENCE) {
unsigned short numlen;
- BLI_stringdec(clip->name, NULL, NULL, &numlen);
+ BLI_path_sequence_decode(clip->name, NULL, NULL, &numlen);
clip->cache->is_still_sequence = (numlen == 0);
}
}
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 78e7dec9f38..77b3f1580ac 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -2066,7 +2066,7 @@ static int ptcache_path(PTCacheID *pid, char *filename)
BLI_path_abs(filename, blendfilename);
}
- return BLI_add_slash(filename); /* new strlen() */
+ return BLI_path_slash_ensure(filename); /* new strlen() */
}
else if (G.relbase_valid || lib) {
char file[MAX_PTCACHE_PATH]; /* we don't want the dir, only the file */
@@ -2083,14 +2083,14 @@ static int ptcache_path(PTCacheID *pid, char *filename)
BLI_snprintf(filename, MAX_PTCACHE_PATH, "//" PTCACHE_PATH "%s", file);
BLI_path_abs(filename, blendfilename);
- return BLI_add_slash(filename); /* new strlen() */
+ return BLI_path_slash_ensure(filename); /* new strlen() */
}
/* use the temp path. this is weak but better then not using point cache at all */
/* temporary directory is assumed to exist and ALWAYS has a trailing slash */
BLI_snprintf(filename, MAX_PTCACHE_PATH, "%s" PTCACHE_PATH, BKE_tempdir_session());
- return BLI_add_slash(filename); /* new strlen() */
+ return BLI_path_slash_ensure(filename); /* new strlen() */
}
static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_path, short do_ext)
diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c
index a2c0434a474..12c5821e858 100644
--- a/source/blender/blenkernel/intern/seqcache.c
+++ b/source/blender/blenkernel/intern/seqcache.c
@@ -243,7 +243,7 @@ static void seq_disk_cache_get_files(SeqDiskCache *disk_cache, char *path)
if (is_dir && !FILENAME_IS_CURRPAR(file)) {
char subpath[FILE_MAX];
BLI_strncpy(subpath, fl->path, sizeof(subpath));
- BLI_add_slash(subpath);
+ BLI_path_slash_ensure(subpath);
seq_disk_cache_get_files(disk_cache, subpath);
}
@@ -439,7 +439,7 @@ static void seq_disk_cache_delete_invalid_files(SeqDiskCache *disk_cache,
DiskCacheFile *next_file, *cache_file = disk_cache->files.first;
char cache_dir[FILE_MAX];
seq_disk_cache_get_dir(disk_cache, scene, seq, cache_dir, sizeof(cache_dir));
- BLI_add_slash(cache_dir);
+ BLI_path_slash_ensure(cache_dir);
while (cache_file) {
next_file = cache_file->next;
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index 4376aefdc25..2b88359861a 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -56,11 +56,11 @@ bool BLI_path_name_at_index(const char *__restrict path,
int *__restrict r_offset,
int *__restrict r_len) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-const char *BLI_last_slash(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-int BLI_add_slash(char *string) ATTR_NONNULL();
-void BLI_del_slash(char *string) ATTR_NONNULL();
-const char *BLI_first_slash(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
-void BLI_path_native_slash(char *path) ATTR_NONNULL();
+const char *BLI_path_slash_rfind(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+int BLI_path_slash_ensure(char *string) ATTR_NONNULL();
+void BLI_path_slash_rstrip(char *string) ATTR_NONNULL();
+const char *BLI_path_slash_find(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+void BLI_path_slash_native(char *path) ATTR_NONNULL();
#ifdef _WIN32
bool BLI_path_program_extensions_add_win32(char *name, const size_t maxlen);
@@ -77,22 +77,22 @@ bool BLI_path_extension_check_glob(const char *str, const char *ext_fnmatch)
bool BLI_path_extension_glob_validate(char *ext_fnmatch) ATTR_NONNULL();
bool BLI_path_extension_replace(char *path, size_t maxlen, const char *ext) ATTR_NONNULL();
bool BLI_path_extension_ensure(char *path, size_t maxlen, const char *ext) ATTR_NONNULL();
-bool BLI_ensure_filename(char *filepath, size_t maxlen, const char *filename) ATTR_NONNULL();
-int BLI_stringdec(const char *string, char *head, char *start, unsigned short *numlen);
-void BLI_stringenc(
+bool BLI_path_filename_ensure(char *filepath, size_t maxlen, const char *filename) ATTR_NONNULL();
+int BLI_path_sequence_decode(const char *string, char *head, char *start, unsigned short *numlen);
+void BLI_path_sequence_encode(
char *string, const char *head, const char *tail, unsigned short numlen, int pic);
-void BLI_cleanup_path(const char *relabase, char *path) ATTR_NONNULL(2);
+void BLI_path_normalize(const char *relabase, char *path) ATTR_NONNULL(2);
/* Same as above but adds a trailing slash. */
-void BLI_cleanup_dir(const char *relabase, char *dir) ATTR_NONNULL(2);
+void BLI_path_normalize_dir(const char *relabase, char *dir) ATTR_NONNULL(2);
bool BLI_filename_make_safe(char *fname) ATTR_NONNULL(1);
bool BLI_path_make_safe(char *path) ATTR_NONNULL(1);
/* Go back one directory. */
-bool BLI_parent_dir(char *path) ATTR_NONNULL();
+bool BLI_path_parent_dir(char *path) ATTR_NONNULL();
/* Go back until the directory is found. */
-bool BLI_parent_dir_until_exists(char *path) ATTR_NONNULL();
+bool BLI_path_parent_dir_until_exists(char *path) ATTR_NONNULL();
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL();
bool BLI_path_frame(char *path, int frame, int digits) ATTR_NONNULL();
@@ -110,7 +110,7 @@ void BLI_path_to_display_name(char *display_name, int maxlen, const char *name)
#if defined(WIN32)
void BLI_cleanup_unc_16(wchar_t *path_16);
-void BLI_cleanup_unc(char *path_16, int maxlen);
+void BLI_path_normalize_unc(char *path_16, int maxlen);
#endif
bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char *sep)
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index 2e402f0c063..26f1de33aa9 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -147,7 +147,7 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
char pardir[FILE_MAXDIR];
BLI_strncpy(pardir, dirname, sizeof(pardir));
- if (BLI_parent_dir(pardir) && (BLI_access(pardir, R_OK) == 0)) {
+ if (BLI_path_parent_dir(pardir) && (BLI_access(pardir, R_OK) == 0)) {
struct dirlink *const dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
if (dlink != NULL) {
dlink->name = BLI_strdup(FILENAME_PARENT);
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index da77046547c..b9133edcae3 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -492,7 +492,7 @@ static bool delete_recursive(const char *dir)
/* dir listing produces dir path without trailing slash... */
BLI_strncpy(path, fl->path, sizeof(path));
- BLI_add_slash(path);
+ BLI_path_slash_ensure(path);
if (delete_recursive(path)) {
err = true;
@@ -562,9 +562,9 @@ int BLI_move(const char *file, const char *to)
BLI_strncpy(str, to, sizeof(str));
/* points 'to' to a directory ? */
- if (BLI_last_slash(str) == (str + strlen(str) - 1)) {
- if (BLI_last_slash(file) != NULL) {
- strcat(str, BLI_last_slash(file) + 1);
+ if (BLI_path_slash_rfind(str) == (str + strlen(str) - 1)) {
+ if (BLI_path_slash_rfind(file) != NULL) {
+ strcat(str, BLI_path_slash_rfind(file) + 1);
}
}
@@ -594,9 +594,9 @@ int BLI_copy(const char *file, const char *to)
BLI_strncpy(str, to, sizeof(str));
/* points 'to' to a directory ? */
- if (BLI_last_slash(str) == (str + strlen(str) - 1)) {
- if (BLI_last_slash(file) != NULL) {
- strcat(str, BLI_last_slash(file) + 1);
+ if (BLI_path_slash_rfind(str) == (str + strlen(str) - 1)) {
+ if (BLI_path_slash_rfind(file) != NULL) {
+ strcat(str, BLI_path_slash_rfind(file) + 1);
}
}
@@ -638,7 +638,7 @@ bool BLI_dir_create_recursive(const char *dirname)
* blah1/blah2 (without slash) */
BLI_strncpy(tmp, dirname, sizeof(tmp));
- BLI_del_slash(tmp);
+ BLI_path_slash_rstrip(tmp);
/* check special case "c:\foo", don't try create "c:", harmless but prints an error below */
if (isalpha(tmp[0]) && (tmp[1] == ':') && tmp[2] == '\0') {
@@ -652,7 +652,7 @@ bool BLI_dir_create_recursive(const char *dirname)
return false;
}
- lslash = (char *)BLI_last_slash(tmp);
+ lslash = (char *)BLI_path_slash_rfind(tmp);
if (lslash) {
/* Split about the last slash and recurse */
@@ -723,7 +723,7 @@ static void join_dirfile_alloc(char **dst, size_t *alloc_len, const char *dir, c
static char *strip_last_slash(const char *dir)
{
char *result = BLI_strdup(dir);
- BLI_del_slash(result);
+ BLI_path_slash_rstrip(result);
return result;
}
@@ -1277,7 +1277,7 @@ static const char *check_destination(const char *file, const char *to)
size_t len = 0;
str = strip_last_slash(file);
- filename = BLI_last_slash(str);
+ filename = BLI_path_slash_rfind(str);
if (!filename) {
MEM_freeN(str);
@@ -1350,9 +1350,9 @@ bool BLI_dir_create_recursive(const char *dirname)
BLI_strncpy(tmp, dirname, size);
/* Avoids one useless recursion in case of '/foo/bar/' path... */
- BLI_del_slash(tmp);
+ BLI_path_slash_rstrip(tmp);
- lslash = (char *)BLI_last_slash(tmp);
+ lslash = (char *)BLI_path_slash_rfind(tmp);
if (lslash) {
/* Split about the last slash and recurse */
*lslash = 0;
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 0bb2ba5859b..ad93b643c5e 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -80,12 +80,12 @@ static bool BLI_path_is_abs(const char *name);
* or from dot if no digits.
* \param r_num_len: Optional to return number of digits found.
*/
-int BLI_stringdec(const char *string, char *head, char *tail, ushort *r_num_len)
+int BLI_path_sequence_decode(const char *string, char *head, char *tail, ushort *r_num_len)
{
uint nums = 0, nume = 0;
int i;
bool found_digit = false;
- const char *const lslash = BLI_last_slash(string);
+ const char *const lslash = BLI_path_slash_rfind(string);
const uint string_len = strlen(string);
const uint lslash_len = lslash != NULL ? (int)(lslash - string) : 0;
uint name_end = string_len;
@@ -151,7 +151,7 @@ int BLI_stringdec(const char *string, char *head, char *tail, ushort *r_num_len)
* Returns in area pointed to by string a string of the form "<head><pic><tail>", where pic
* is formatted as numlen digits with leading zeroes.
*/
-void BLI_stringenc(
+void BLI_path_sequence_encode(
char *string, const char *head, const char *tail, unsigned short numlen, int pic)
{
sprintf(string, "%s%.*d%s", head, numlen, MAX2(0, pic), tail);
@@ -170,7 +170,7 @@ static int BLI_path_unc_prefix_len(const char *path); /* defined below in same f
*
* \note \a path isn't protected for max string names...
*/
-void BLI_cleanup_path(const char *relabase, char *path)
+void BLI_path_normalize(const char *relabase, char *path)
{
ptrdiff_t a;
char *start, *eind;
@@ -263,10 +263,10 @@ void BLI_cleanup_path(const char *relabase, char *path)
/**
* Cleanup filepath ensuring a trailing slash.
*/
-void BLI_cleanup_dir(const char *relabase, char *dir)
+void BLI_path_normalize_dir(const char *relabase, char *dir)
{
- BLI_cleanup_path(relabase, dir);
- BLI_add_slash(dir);
+ BLI_path_normalize(relabase, dir);
+ BLI_path_slash_ensure(dir);
}
/**
@@ -381,8 +381,8 @@ bool BLI_path_make_safe(char *path)
}
#endif
- for (curr_slash = (char *)BLI_first_slash(curr_path); curr_slash;
- curr_slash = (char *)BLI_first_slash(curr_path)) {
+ for (curr_slash = (char *)BLI_path_slash_find(curr_path); curr_slash;
+ curr_slash = (char *)BLI_path_slash_find(curr_path)) {
const char backup = *curr_slash;
*curr_slash = '\0';
if (!skip_first && (*curr_path != '\0') && BLI_filename_make_safe(curr_path)) {
@@ -494,7 +494,7 @@ static void BLI_path_unc_to_short(wchar_t *unc)
}
}
-void BLI_cleanup_unc(char *path, int maxlen)
+void BLI_path_normalize_unc(char *path, int maxlen)
{
wchar_t *tmp_16 = alloc_utf16_from_8(path, 1);
BLI_cleanup_unc_16(tmp_16);
@@ -578,11 +578,11 @@ void BLI_path_rel(char *file, const char *relfile)
BLI_str_replace_char(file + BLI_path_unc_prefix_len(file), '\\', '/');
/* remove /./ which confuse the following slash counting... */
- BLI_cleanup_path(NULL, file);
- BLI_cleanup_path(NULL, temp);
+ BLI_path_normalize(NULL, file);
+ BLI_path_normalize(NULL, temp);
/* the last slash in the file indicates where the path part ends */
- lslash = BLI_last_slash(temp);
+ lslash = BLI_path_slash_rfind(temp);
if (lslash) {
/* find the prefix of the filename that is equal for both filenames.
@@ -701,13 +701,13 @@ bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char
* Replaces path with the path of its parent directory, returning true if
* it was able to find a parent directory within the pathname.
*/
-bool BLI_parent_dir(char *path)
+bool BLI_path_parent_dir(char *path)
{
const char parent_dir[] = {'.', '.', SEP, '\0'}; /* "../" or "..\\" */
char tmp[FILE_MAX + 4];
BLI_join_dirfile(tmp, sizeof(tmp), path, parent_dir);
- BLI_cleanup_path(NULL, tmp); /* does all the work of normalizing the path for us */
+ BLI_path_normalize(NULL, tmp); /* does all the work of normalizing the path for us */
if (!BLI_path_extension_check(tmp, parent_dir)) {
strcpy(path, tmp); /* We assume pardir is always shorter... */
@@ -722,12 +722,12 @@ bool BLI_parent_dir(char *path)
* Strips off nonexistent (or non-accessible) subdirectories from the end of *dir,
* leaving the path of the lowest-level directory that does exist and we can read.
*/
-bool BLI_parent_dir_until_exists(char *dir)
+bool BLI_path_parent_dir_until_exists(char *dir)
{
bool valid_path = true;
/* Loop as long as cur path is not a dir, and we can get a parent path. */
- while ((BLI_access(dir, R_OK) != 0) && (valid_path = BLI_parent_dir(dir))) {
+ while ((BLI_access(dir, R_OK) != 0) && (valid_path = BLI_path_parent_dir(dir))) {
/* pass */
}
return (valid_path && dir[0]);
@@ -777,7 +777,7 @@ static bool stringframe_chars(const char *path, int *char_start, int *char_end)
*/
static void ensure_digits(char *path, int digits)
{
- char *file = (char *)BLI_last_slash(path);
+ char *file = (char *)BLI_path_slash_rfind(path);
if (file == NULL) {
file = path;
@@ -852,7 +852,7 @@ bool BLI_path_frame_range(char *path, int sta, int end, int digits)
bool BLI_path_frame_get(char *path, int *r_frame, int *r_numdigits)
{
if (*path) {
- char *file = (char *)BLI_last_slash(path);
+ char *file = (char *)BLI_path_slash_rfind(path);
char *c;
int len, numdigits;
@@ -908,7 +908,7 @@ void BLI_path_frame_strip(char *path, char *r_ext)
return;
}
- char *file = (char *)BLI_last_slash(path);
+ char *file = (char *)BLI_path_slash_rfind(path);
char *c, *suffix;
int len;
int numdigits = 0;
@@ -1075,8 +1075,8 @@ bool BLI_path_abs(char *path, const char *basepath)
BLI_strncpy(base, basepath, sizeof(base));
/* file component is ignored, so don't bother with the trailing slash */
- BLI_cleanup_path(NULL, base);
- lslash = BLI_last_slash(base);
+ BLI_path_normalize(NULL, base);
+ lslash = BLI_path_slash_rfind(base);
BLI_str_replace_char(base + BLI_path_unc_prefix_len(base), '\\', '/');
if (lslash) {
@@ -1110,7 +1110,7 @@ bool BLI_path_abs(char *path, const char *basepath)
#endif
/* ensure this is after correcting for path switch */
- BLI_cleanup_path(NULL, path);
+ BLI_path_normalize(NULL, path);
return wasrelative;
}
@@ -1363,7 +1363,7 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c
/* Get the file name, chop everything past the last slash (ie. the filename) */
strcpy(string, relabase);
- lslash = (char *)BLI_last_slash(string);
+ lslash = (char *)BLI_path_slash_rfind(string);
if (lslash) {
*(lslash + 1) = 0;
}
@@ -1418,7 +1418,7 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c
strcat(string, file);
/* Push all slashes to the system preferred direction */
- BLI_path_native_slash(string);
+ BLI_path_slash_native(string);
}
static bool path_extension_check_ex(const char *str,
@@ -1608,12 +1608,12 @@ bool BLI_path_extension_ensure(char *path, size_t maxlen, const char *ext)
return true;
}
-bool BLI_ensure_filename(char *filepath, size_t maxlen, const char *filename)
+bool BLI_path_filename_ensure(char *filepath, size_t maxlen, const char *filename)
{
#ifdef DEBUG_STRSIZE
memset(filepath, 0xff, sizeof(*filepath) * maxlen);
#endif
- char *c = (char *)BLI_last_slash(filepath);
+ char *c = (char *)BLI_path_slash_rfind(filepath);
if (!c || ((c - filepath) < maxlen - (strlen(filename) + 1))) {
strcpy(c ? &c[1] : filepath, filename);
return true;
@@ -1636,7 +1636,7 @@ void BLI_split_dirfile(
memset(dir, 0xff, sizeof(*dir) * dirlen);
memset(file, 0xff, sizeof(*file) * filelen);
#endif
- const char *lslash_str = BLI_last_slash(string);
+ const char *lslash_str = BLI_path_slash_rfind(string);
const size_t lslash = lslash_str ? (size_t)(lslash_str - string) + 1 : 0;
if (dir) {
@@ -1680,7 +1680,7 @@ const char *BLI_path_extension(const char *filepath)
if (extension == NULL) {
return NULL;
}
- if (BLI_first_slash(extension) != NULL) {
+ if (BLI_path_slash_find(extension) != NULL) {
/* There is a path separator in the extension, so the '.' was found in a
* directory component and not in the filename. */
return NULL;
@@ -1695,7 +1695,7 @@ void BLI_path_append(char *__restrict dst, const size_t maxlen, const char *__re
{
size_t dirlen = BLI_strnlen(dst, maxlen);
- /* inline BLI_add_slash */
+ /* inline BLI_path_slash_ensure */
if ((dirlen > 0) && (dst[dirlen - 1] != SEP)) {
dst[dirlen++] = SEP;
dst[dirlen] = '\0';
@@ -1738,7 +1738,7 @@ void BLI_join_dirfile(char *__restrict dst,
return; /* fills the path */
}
- /* inline BLI_add_slash */
+ /* inline BLI_path_slash_ensure */
if ((dirlen > 0) && !ELEM(dst[dirlen - 1], SEP, ALTSEP)) {
dst[dirlen++] = SEP;
dst[dirlen] = '\0';
@@ -1846,7 +1846,7 @@ size_t BLI_path_join(char *__restrict dst, const size_t dst_len, const char *pat
*/
const char *BLI_path_basename(const char *path)
{
- const char *const filename = BLI_last_slash(path);
+ const char *const filename = BLI_path_slash_rfind(path);
return filename ? filename + 1 : path;
}
@@ -1921,7 +1921,7 @@ bool BLI_path_name_at_index(const char *__restrict path,
/**
* Returns pointer to the leftmost path separator in string. Not actually used anywhere.
*/
-const char *BLI_first_slash(const char *string)
+const char *BLI_path_slash_find(const char *string)
{
const char *const ffslash = strchr(string, '/');
const char *const fbslash = strchr(string, '\\');
@@ -1939,7 +1939,7 @@ const char *BLI_first_slash(const char *string)
/**
* Returns pointer to the rightmost path separator in string.
*/
-const char *BLI_last_slash(const char *string)
+const char *BLI_path_slash_rfind(const char *string)
{
const char *const lfslash = strrchr(string, '/');
const char *const lbslash = strrchr(string, '\\');
@@ -1958,7 +1958,7 @@ const char *BLI_last_slash(const char *string)
* Appends a slash to string if there isn't one there already.
* Returns the new length of the string.
*/
-int BLI_add_slash(char *string)
+int BLI_path_slash_ensure(char *string)
{
int len = strlen(string);
if (len == 0 || string[len - 1] != SEP) {
@@ -1972,7 +1972,7 @@ int BLI_add_slash(char *string)
/**
* Removes the last slash and everything after it to the end of string, if there is one.
*/
-void BLI_del_slash(char *string)
+void BLI_path_slash_rstrip(char *string)
{
int len = strlen(string);
while (len) {
@@ -1989,7 +1989,7 @@ void BLI_del_slash(char *string)
/**
* Changes to the path separators to the native ones for this OS.
*/
-void BLI_path_native_slash(char *path)
+void BLI_path_slash_native(char *path)
{
#ifdef WIN32
if (path && BLI_strnlen(path, 3) > 2) {
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index a47c2e3ea13..07cd39e2559 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -664,7 +664,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
char name1[FILE_MAX];
BLI_strncpy(name1, filepath, sizeof(name1));
- BLI_cleanup_path(relabase, name1);
+ BLI_path_normalize(relabase, name1);
// printf("blo_find_main: relabase %s\n", relabase);
// printf("blo_find_main: original in %s\n", filepath);
@@ -1680,7 +1680,7 @@ bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, cha
strcpy(r_dir, path);
- while ((slash = (char *)BLI_last_slash(r_dir))) {
+ while ((slash = (char *)BLI_path_slash_rfind(r_dir))) {
char tc = *slash;
*slash = '\0';
if (BLO_has_bfile_extension(r_dir) && BLI_is_file(r_dir)) {
@@ -8436,7 +8436,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));
- BLI_cleanup_path(fd->relabase, lib->filepath);
+ BLI_path_normalize(fd->relabase, lib->filepath);
// printf("direct_link_library: name %s\n", lib->name);
// printf("direct_link_library: filepath %s\n", lib->filepath);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index f0280c78407..fc6ec80e09a 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -4348,8 +4348,8 @@ bool BLO_write_file(Main *mainvar,
BLI_split_dir_part(filepath, dir_dst, sizeof(dir_dst));
/* Just in case there is some subtle difference. */
- BLI_cleanup_path(mainvar->name, dir_dst);
- BLI_cleanup_path(mainvar->name, dir_src);
+ BLI_path_normalize(mainvar->name, dir_dst);
+ BLI_path_normalize(mainvar->name, dir_src);
if (G.relbase_valid && (BLI_path_cmp(dir_dst, dir_src) == 0)) {
/* Saved to same path. Nothing to do. */
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index e2affa7bc36..9af623d8065 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -110,7 +110,7 @@ static int file_browse_exec(bContext *C, wmOperator *op)
if (BLI_is_dir(path)) {
/* do this first so '//' isnt converted to '//\' on windows */
- BLI_add_slash(path);
+ BLI_path_slash_ensure(path);
if (is_relative) {
BLI_strncpy(path, str, FILE_MAX);
BLI_path_rel(path, BKE_main_blendfile_path(bmain));
@@ -122,7 +122,7 @@ static int file_browse_exec(bContext *C, wmOperator *op)
}
}
else {
- char *const lslash = (char *)BLI_last_slash(str);
+ char *const lslash = (char *)BLI_path_slash_rfind(str);
if (lslash) {
lslash[1] = '\0';
}
@@ -187,7 +187,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
PointerRNA props_ptr;
if (event->alt) {
- char *lslash = (char *)BLI_last_slash(str);
+ char *lslash = (char *)BLI_path_slash_rfind(str);
if (lslash) {
*lslash = '\0';
}
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c
index dc85b3959e1..3b1cc6fcab0 100644
--- a/source/blender/editors/space_clip/clip_buttons.c
+++ b/source/blender/editors/space_clip/clip_buttons.c
@@ -872,7 +872,7 @@ void uiTemplateMovieclipInformation(uiLayout *layout,
if (framenr <= clip->len) {
BKE_movieclip_filename_for_frame(clip, user, filepath);
- file = BLI_last_slash(filepath);
+ file = BLI_path_slash_rfind(filepath);
}
else {
file = "-";
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 48bc885405d..266212fdfd7 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -286,7 +286,7 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
BLI_strncpy(path, clip->name, sizeof(path));
BLI_path_abs(path, CTX_data_main(C)->name);
- BLI_parent_dir(path);
+ BLI_path_parent_dir(path);
}
else {
BLI_strncpy(path, U.textudir, sizeof(path));
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 7cce243696d..a5263378850 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -211,7 +211,7 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen)
else {
if (is_parent_dir) {
/* avoids /../../ */
- BLI_parent_dir(params->dir);
+ BLI_path_parent_dir(params->dir);
if (params->recursion_level > 1) {
/* Disable 'dirtree' recursion when going up in tree. */
@@ -220,9 +220,9 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen)
}
}
else {
- BLI_cleanup_dir(BKE_main_blendfile_path(bmain), params->dir);
+ BLI_path_normalize_dir(BKE_main_blendfile_path(bmain), params->dir);
strcat(params->dir, file->relpath);
- BLI_add_slash(params->dir);
+ BLI_path_slash_ensure(params->dir);
}
ED_file_change_dir(C);
@@ -940,7 +940,7 @@ static int bookmark_select_exec(bContext *C, wmOperator *op)
RNA_property_string_get(op->ptr, prop, entry);
BLI_strncpy(params->dir, entry, sizeof(params->dir));
- BLI_cleanup_dir(BKE_main_blendfile_path(bmain), params->dir);
+ BLI_path_normalize_dir(BKE_main_blendfile_path(bmain), params->dir);
ED_file_change_dir(C);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
@@ -1627,12 +1627,12 @@ static int file_exec(bContext *C, wmOperator *exec_op)
}
if (FILENAME_IS_PARENT(file->relpath)) {
- BLI_parent_dir(sfile->params->dir);
+ BLI_path_parent_dir(sfile->params->dir);
}
else {
- BLI_cleanup_path(BKE_main_blendfile_path(bmain), sfile->params->dir);
+ BLI_path_normalize(BKE_main_blendfile_path(bmain), sfile->params->dir);
BLI_path_append(sfile->params->dir, sizeof(sfile->params->dir) - 1, file->relpath);
- BLI_add_slash(sfile->params->dir);
+ BLI_path_slash_ensure(sfile->params->dir);
}
if (file->redirection_path) {
STRNCPY(sfile->params->dir, file->redirection_path);
@@ -1754,8 +1754,8 @@ static int file_parent_exec(bContext *C, wmOperator *UNUSED(unused))
SpaceFile *sfile = CTX_wm_space_file(C);
if (sfile->params) {
- if (BLI_parent_dir(sfile->params->dir)) {
- BLI_cleanup_dir(BKE_main_blendfile_path(bmain), sfile->params->dir);
+ if (BLI_path_parent_dir(sfile->params->dir)) {
+ BLI_path_normalize_dir(BKE_main_blendfile_path(bmain), sfile->params->dir);
ED_file_change_dir(C);
if (sfile->params->recursion_level > 1) {
/* Disable 'dirtree' recursion when going up in tree. */
@@ -2274,7 +2274,7 @@ static void file_expand_directory(bContext *C)
sfile->params->dir[3] = '\0';
}
else if (BLI_path_is_unc(sfile->params->dir)) {
- BLI_cleanup_unc(sfile->params->dir, FILE_MAX_LIBEXTRA);
+ BLI_path_normalize_unc(sfile->params->dir, FILE_MAX_LIBEXTRA);
}
#endif
}
@@ -2291,7 +2291,7 @@ static bool can_create_dir(const char *dir)
if (BLI_path_is_unc(dir)) {
char parent[PATH_MAX];
BLI_strncpy(parent, dir, PATH_MAX);
- BLI_parent_dir(parent);
+ BLI_path_parent_dir(parent);
return BLI_is_dir(parent);
}
return true;
@@ -2338,7 +2338,7 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
}
}
- BLI_cleanup_dir(BKE_main_blendfile_path(bmain), sfile->params->dir);
+ BLI_path_normalize_dir(BKE_main_blendfile_path(bmain), sfile->params->dir);
if (filelist_is_dir(sfile->files, sfile->params->dir)) {
if (!STREQ(sfile->params->dir, old_dir)) { /* Avoids flickering when nothing's changed. */
@@ -2423,7 +2423,7 @@ void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg
/* if directory, open it and empty filename field */
if (filelist_is_dir(sfile->files, filepath)) {
- BLI_cleanup_dir(BKE_main_blendfile_path(bmain), filepath);
+ BLI_path_normalize_dir(BKE_main_blendfile_path(bmain), filepath);
BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir));
sfile->params->file[0] = '\0';
ED_file_change_dir(C);
@@ -2487,7 +2487,7 @@ static bool file_filenum_poll(bContext *C)
}
/**
- * Looks for a string of digits within name (using BLI_stringdec) and adjusts it by add.
+ * Looks for a string of digits within name (using BLI_path_sequence_decode) and adjusts it by add.
*/
static void filenum_newname(char *name, size_t name_size, int add)
{
@@ -2496,7 +2496,7 @@ static void filenum_newname(char *name, size_t name_size, int add)
int pic;
ushort digits;
- pic = BLI_stringdec(name, head, tail, &digits);
+ pic = BLI_path_sequence_decode(name, head, tail, &digits);
/* are we going from 100 -> 99 or from 10 -> 9 */
if (add < 0 && digits > 0) {
@@ -2514,7 +2514,7 @@ static void filenum_newname(char *name, size_t name_size, int add)
if (pic < 0) {
pic = 0;
}
- BLI_stringenc(name_temp, head, tail, digits, pic);
+ BLI_path_sequence_encode(name_temp, head, tail, digits, pic);
BLI_strncpy(name, name_temp, name_size);
}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 126430986a5..778c27e1a17 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -635,7 +635,7 @@ static bool is_hidden_dot_filename(const char *filename, FileListInternEntry *fi
/* filename might actually be a piece of path, in which case we have to check all its parts. */
bool hidden = false;
- char *sep = (char *)BLI_last_slash(filename);
+ char *sep = (char *)BLI_path_slash_rfind(filename);
if (!hidden && sep) {
char tmp_filename[FILE_MAX_LIBEXTRA];
@@ -654,7 +654,7 @@ static bool is_hidden_dot_filename(const char *filename, FileListInternEntry *fi
break;
}
*sep = '\0';
- sep = (char *)BLI_last_slash(tmp_filename);
+ sep = (char *)BLI_path_slash_rfind(tmp_filename);
}
}
return hidden;
@@ -1023,7 +1023,7 @@ static int filelist_geticon_ex(FileDirEntry *file,
FSMenuEntry *tfsm = ED_fsmenu_get_category(fsmenu, categories[i]);
char fullpath[FILE_MAX_LIBEXTRA];
BLI_join_dirfile(fullpath, sizeof(fullpath), root, file->relpath);
- BLI_add_slash(fullpath);
+ BLI_path_slash_ensure(fullpath);
for (; tfsm; tfsm = tfsm->next) {
if (STREQ(tfsm->path, fullpath)) {
/* Never want a little folder inside a large one. */
@@ -1112,7 +1112,7 @@ int filelist_geticon(struct FileList *filelist, const int index, const bool is_m
static void parent_dir_until_exists_or_default_root(char *dir)
{
- if (!BLI_parent_dir_until_exists(dir)) {
+ if (!BLI_path_parent_dir_until_exists(dir)) {
#ifdef WIN32
get_default_root(dir);
#else
@@ -1624,7 +1624,7 @@ void filelist_setdir(struct FileList *filelist, char *r_dir)
{
BLI_assert(strlen(r_dir) < FILE_MAX_LIBEXTRA);
- BLI_cleanup_dir(BKE_main_blendfile_path_from_global(), r_dir);
+ BLI_path_normalize_dir(BKE_main_blendfile_path_from_global(), r_dir);
const bool is_valid_path = filelist->checkdirf(filelist, r_dir, true);
BLI_assert(is_valid_path);
UNUSED_VARS_NDEBUG(is_valid_path);
@@ -2448,7 +2448,7 @@ static int groupname_to_code(const char *group)
BLI_assert(group);
BLI_strncpy(buf, group, sizeof(buf));
- lslash = (char *)BLI_last_slash(buf);
+ lslash = (char *)BLI_path_slash_rfind(buf);
if (lslash) {
lslash[0] = '\0';
}
@@ -2816,7 +2816,7 @@ static void filelist_readjob_do(const bool do_lib,
BLI_strncpy(dir, filelist->filelist.root, sizeof(dir));
BLI_strncpy(filter_glob, filelist->filter_data.filter_glob, sizeof(filter_glob));
- BLI_cleanup_dir(main_name, dir);
+ BLI_path_normalize_dir(main_name, dir);
td_dir->dir = BLI_strdup(dir);
while (!BLI_stack_is_empty(todo_dirs) && !(*stop)) {
@@ -2842,7 +2842,7 @@ static void filelist_readjob_do(const bool do_lib,
* Note that in the end, this means we 'cache' valid relative subdir once here,
* this is actually better. */
BLI_strncpy(rel_subdir, subdir, sizeof(rel_subdir));
- BLI_cleanup_dir(root, rel_subdir);
+ BLI_path_normalize_dir(root, rel_subdir);
BLI_path_rel(rel_subdir, root);
if (do_lib) {
@@ -2884,7 +2884,7 @@ static void filelist_readjob_do(const bool do_lib,
else {
/* We have a directory we want to list, add it to todo list! */
BLI_join_dirfile(dir, sizeof(dir), root, entry->relpath);
- BLI_cleanup_dir(main_name, dir);
+ BLI_path_normalize_dir(main_name, dir);
td_dir = BLI_stack_push_r(todo_dirs);
td_dir->level = recursion_level + 1;
td_dir->dir = BLI_strdup(dir);
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 67c0fae3565..6b594c02c15 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -156,7 +156,7 @@ short ED_fileselect_set_params(SpaceFile *sfile)
}
if (params->dir[0]) {
- BLI_cleanup_dir(blendfile_path, params->dir);
+ BLI_path_normalize_dir(blendfile_path, params->dir);
BLI_path_abs(params->dir, blendfile_path);
}
@@ -924,7 +924,7 @@ int autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v))
match = UI_autocomplete_end(autocpl, str);
if (match == AUTOCOMPLETE_FULL_MATCH) {
- BLI_add_slash(str);
+ BLI_path_slash_ensure(str);
}
}
}
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 873091bd68d..3658ebae3a2 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -1276,7 +1276,7 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
}
else if (ima->source == IMA_SRC_SEQUENCE && ibuf) {
/* Image sequence frame number + filename */
- const char *filename = BLI_last_slash(ibuf->name);
+ const char *filename = BLI_path_slash_rfind(ibuf->name);
filename = (filename == NULL) ? ibuf->name : filename + 1;
BLI_snprintf(str, MAX_IMAGE_INFO_LEN, TIP_("Frame %d: %s"), framenr, filename);
}
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 67e64c52051..14245327bdd 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1794,7 +1794,8 @@ static int image_save_options_init(Main *bmain,
}
/* append UDIM numbering if not present */
- if (ima->source == IMA_SRC_TILED && (BLI_stringdec(ima->name, NULL, NULL, NULL) != 1001)) {
+ if (ima->source == IMA_SRC_TILED &&
+ (BLI_path_sequence_decode(ima->name, NULL, NULL, NULL) != 1001)) {
int len = strlen(opts->filepath);
STR_CONCAT(opts->filepath, len, ".1001");
}
diff --git a/source/blender/editors/space_image/image_sequence.c b/source/blender/editors/space_image/image_sequence.c
index 8b298045597..e65924d0eb9 100644
--- a/source/blender/editors/space_image/image_sequence.c
+++ b/source/blender/editors/space_image/image_sequence.c
@@ -74,7 +74,7 @@ static void image_sequence_get_frame_ranges(wmOperator *op, ListBase *ranges)
ImageFrame *frame = MEM_callocN(sizeof(ImageFrame), "image_frame");
/* use the first file in the list as base filename */
- frame->framenr = BLI_stringdec(filename, head, tail, &digits);
+ frame->framenr = BLI_path_sequence_decode(filename, head, tail, &digits);
/* still in the same sequence */
if (do_frame_range && (range != NULL) && (STREQLEN(base_head, head, FILE_MAX)) &&
@@ -127,7 +127,7 @@ static int image_get_udim(char *filepath, ListBase *udim_tiles)
ushort digits;
char base_head[FILE_MAX], base_tail[FILE_MAX];
- int id = BLI_stringdec(filename, base_head, base_tail, &digits);
+ int id = BLI_path_sequence_decode(filename, base_head, base_tail, &digits);
if (id < 1001 || id >= IMA_UDIM_MAX) {
return 0;
@@ -144,7 +144,7 @@ static int image_get_udim(char *filepath, ListBase *udim_tiles)
continue;
}
char head[FILE_MAX], tail[FILE_MAX];
- id = BLI_stringdec(dir[i].relname, head, tail, &digits);
+ id = BLI_path_sequence_decode(dir[i].relname, head, tail, &digits);
if (digits > 4 || !(STREQLEN(base_head, head, FILE_MAX)) ||
!(STREQLEN(base_tail, tail, FILE_MAX))) {
@@ -166,7 +166,7 @@ static int image_get_udim(char *filepath, ListBase *udim_tiles)
if (is_udim && has_primary) {
char primary_filename[FILE_MAX];
- BLI_stringenc(primary_filename, base_head, base_tail, digits, 1001);
+ BLI_path_sequence_encode(primary_filename, base_head, base_tail, digits, 1001);
BLI_join_dirfile(filepath, FILE_MAX, dirname, primary_filename);
return max_udim - 1000;
}
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index f7da64624e0..c2f6796bf31 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -349,7 +349,7 @@ int Controller::LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph
soc string basename((const char *)qfi.fileName().toAscii().data());
char cleaned[FILE_MAX];
BLI_strncpy(cleaned, iFileName, FILE_MAX);
- BLI_cleanup_path(NULL, cleaned);
+ BLI_path_normalize(NULL, cleaned);
string basename = string(cleaned);
#endif
diff --git a/source/blender/freestyle/intern/system/StringUtils.cpp b/source/blender/freestyle/intern/system/StringUtils.cpp
index 58d84010574..cd85aaaa5ff 100644
--- a/source/blender/freestyle/intern/system/StringUtils.cpp
+++ b/source/blender/freestyle/intern/system/StringUtils.cpp
@@ -48,7 +48,7 @@ void getPathName(const string &path, const string &base, vector<string> &pathnam
dir = path.substr(pos, sep - pos);
BLI_strncpy(cleaned, dir.c_str(), FILE_MAX);
- BLI_cleanup_path(NULL, cleaned);
+ BLI_path_normalize(NULL, cleaned);
res = string(cleaned);
if (!base.empty()) {
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index e9ac40de442..11b30a24cde 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -154,7 +154,7 @@ static int an_stringdec(const char *string, char *head, char *tail, unsigned sho
static void an_stringenc(
char *string, const char *head, const char *tail, unsigned short numlen, int pic)
{
- BLI_stringenc(string, head, tail, numlen, pic);
+ BLI_path_sequence_encode(string, head, tail, numlen, pic);
}
#ifdef WITH_AVI
diff --git a/source/blender/io/collada/ImageExporter.cpp b/source/blender/io/collada/ImageExporter.cpp
index 9d2b873f862..1cd3301b8a8 100644
--- a/source/blender/io/collada/ImageExporter.cpp
+++ b/source/blender/io/collada/ImageExporter.cpp
@@ -108,7 +108,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
/* make absolute source path */
BLI_strncpy(source_path, image->name, sizeof(source_path));
BLI_path_abs(source_path, ID_BLEND_PATH_FROM_GLOBAL(&image->id));
- BLI_cleanup_path(NULL, source_path);
+ BLI_path_normalize(NULL, source_path);
if (use_copies) {
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index b107c89388d..f52307355c2 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -544,7 +544,7 @@ static void rna_Userdef_disk_cache_dir_update(Main *UNUSED(bmain),
{
if (U.sequencer_disk_cache_dir[0] != '\0') {
BLI_path_abs(U.sequencer_disk_cache_dir, BKE_main_blendfile_path_from_global());
- BLI_add_slash(U.sequencer_disk_cache_dir);
+ BLI_path_slash_ensure(U.sequencer_disk_cache_dir);
BLI_path_make_safe(U.sequencer_disk_cache_dir);
}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 95c7afcbf15..fe4305830ab 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -2298,7 +2298,7 @@ static bool wm_open_mainfile_check(bContext *UNUSED(C), wmOperator *op)
RNA_string_get(op->ptr, "filepath", path);
/* get the dir */
- lslash = (char *)BLI_last_slash(path);
+ lslash = (char *)BLI_path_slash_rfind(path);
if (lslash) {
*(lslash + 1) = '\0';
}
@@ -2536,7 +2536,7 @@ void WM_OT_recover_auto_save(wmOperatorType *ot)
static void wm_filepath_default(char *filepath)
{
if (G.save_over == false) {
- BLI_ensure_filename(filepath, FILE_MAX, "untitled.blend");
+ BLI_path_filename_ensure(filepath, FILE_MAX, "untitled.blend");
}
}
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index 5acc8a5fbc6..da4e4160724 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -104,7 +104,7 @@ static int wm_link_append_invoke(bContext *C, wmOperator *op, const wmEvent *UNU
else if (G.relbase_valid) {
char path[FILE_MAX];
BLI_strncpy(path, BKE_main_blendfile_path_from_global(), sizeof(path));
- BLI_parent_dir(path);
+ BLI_path_parent_dir(path);
RNA_string_set(op->ptr, "filepath", path);
}
}
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 8a872010ecc..84f099b0dbc 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -429,7 +429,8 @@ static void build_pict_list_ex(
} fp_decoded;
BLI_strncpy(filepath, first, sizeof(filepath));
- fp_framenr = BLI_stringdec(filepath, fp_decoded.head, fp_decoded.tail, &fp_decoded.digits);
+ fp_framenr = BLI_path_sequence_decode(
+ filepath, fp_decoded.head, fp_decoded.tail, &fp_decoded.digits);
pupdate_time();
ptottime = 1.0;
@@ -522,7 +523,8 @@ static void build_pict_list_ex(
/* create a new filepath each time */
fp_framenr += fstep;
- BLI_stringenc(filepath, fp_decoded.head, fp_decoded.tail, fp_decoded.digits, fp_framenr);
+ BLI_path_sequence_encode(
+ filepath, fp_decoded.head, fp_decoded.tail, fp_decoded.digits, fp_framenr);
while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0))) {
GHOST_DispatchEvents(g_WS.ghost_system);
diff --git a/tests/gtests/blenlib/BLI_path_util_test.cc b/tests/gtests/blenlib/BLI_path_util_test.cc
index 18d7a9c4fea..480d48d6080 100644
--- a/tests/gtests/blenlib/BLI_path_util_test.cc
+++ b/tests/gtests/blenlib/BLI_path_util_test.cc
@@ -58,59 +58,59 @@ char *zLhm65070058860608_br_find_exe(const char *default_exe)
/* -------------------------------------------------------------------- */
/* tests */
-/* BLI_cleanup_path */
+/* BLI_path_normalize */
#ifndef _WIN32
TEST(path_util, Clean)
{
/* "/./" -> "/" */
{
char path[FILE_MAX] = "/a/./b/./c/./";
- BLI_cleanup_path(NULL, path);
+ BLI_path_normalize(NULL, path);
EXPECT_STREQ("/a/b/c/", path);
}
{
char path[FILE_MAX] = "/./././";
- BLI_cleanup_path(NULL, path);
+ BLI_path_normalize(NULL, path);
EXPECT_STREQ("/", path);
}
{
char path[FILE_MAX] = "/a/./././b/";
- BLI_cleanup_path(NULL, path);
+ BLI_path_normalize(NULL, path);
EXPECT_STREQ("/a/b/", path);
}
/* "//" -> "/" */
{
char path[FILE_MAX] = "a////";
- BLI_cleanup_path(NULL, path);
+ BLI_path_normalize(NULL, path);
EXPECT_STREQ("a/", path);
}
if (0) /* FIXME */
{
char path[FILE_MAX] = "./a////";
- BLI_cleanup_path(NULL, path);
+ BLI_path_normalize(NULL, path);
EXPECT_STREQ("./a/", path);
}
/* "foo/bar/../" -> "foo/" */
{
char path[FILE_MAX] = "/a/b/c/../../../";
- BLI_cleanup_path(NULL, path);
+ BLI_path_normalize(NULL, path);
EXPECT_STREQ("/", path);
}
{
char path[FILE_MAX] = "/a/../a/b/../b/c/../c/";
- BLI_cleanup_path(NULL, path);
+ BLI_path_normalize(NULL, path);
EXPECT_STREQ("/a/b/c/", path);
}
{
char path[FILE_MAX] = "//../";
- BLI_cleanup_path("/a/b/c/", path);
+ BLI_path_normalize("/a/b/c/", path);
EXPECT_STREQ("/a/b/", path);
}
}