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 /source/blender/blenkernel
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.
Diffstat (limited to 'source/blender/blenkernel')
-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
8 files changed, 27 insertions, 27 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;