[Bf-blender-cvs] [b839a5d0765] master: Cleanup: remove BLI_cleanup_file

Campbell Barton noreply at git.blender.org
Fri Mar 6 14:20:23 CET 2020


Commit: b839a5d0765bd449fb4f3a58ed683ec0233a8acf
Author: Campbell Barton
Date:   Sat Mar 7 00:13:03 2020 +1100
Branches: master
https://developer.blender.org/rBb839a5d0765bd449fb4f3a58ed683ec0233a8acf

Cleanup: remove BLI_cleanup_file

In practice, references to files rarely have trailing slashes
(by accident). Remove this function in favor of BLI_cleanup_path.

===================================================================

M	source/blender/blenkernel/intern/bpath.c
M	source/blender/blenlib/BLI_path_util.h
M	source/blender/blenlib/intern/path_util.c
M	source/blender/freestyle/intern/application/Controller.cpp
M	source/blender/freestyle/intern/system/StringUtils.cpp

===================================================================

diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index 26e8bbde009..38f0e516beb 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -807,13 +807,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_file, but we do it explicitly so we know if it changed. */
+   * BLI_cleanup_path, 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_dir runs before the path is made relative
      * because it wont work for paths that start with "//../" */
-    BLI_cleanup_file(base_new, filepath);
+    BLI_cleanup_path(base_new, filepath);
     BLI_path_rel(filepath, base_new);
     BLI_strncpy(path_dst, filepath, FILE_MAX);
     return true;
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index ec911c11a8c..d4e3ebdb2e1 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -81,12 +81,9 @@ int BLI_stringdec(const char *string, char *head, char *start, unsigned short *n
 void BLI_stringenc(
     char *string, const char *head, const char *tail, unsigned short numlen, int pic);
 
-/* removes trailing slash */
-void BLI_cleanup_file(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);
-/* doesn't touch trailing slash */
 void BLI_cleanup_path(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);
 
 bool BLI_filename_make_safe(char *fname) ATTR_NONNULL(1);
 bool BLI_path_make_safe(char *path) ATTR_NONNULL(1);
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index e3c455fe417..48148fc1134 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -269,15 +269,6 @@ void BLI_cleanup_dir(const char *relabase, char *dir)
   BLI_add_slash(dir);
 }
 
-/**
- * Cleanup filepath ensuring no trailing slash.
- */
-void BLI_cleanup_file(const char *relabase, char *path)
-{
-  BLI_cleanup_path(relabase, path);
-  BLI_del_slash(path);
-}
-
 /**
  * Make given name safe to be used in paths.
  *
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index ef05d0a3a8f..c852cda6c8c 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -347,7 +347,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_file(NULL, cleaned);
+  BLI_cleanup_path(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 5e56dba17bf..23f454c0a04 100644
--- a/source/blender/freestyle/intern/system/StringUtils.cpp
+++ b/source/blender/freestyle/intern/system/StringUtils.cpp
@@ -46,7 +46,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_file(NULL, cleaned);
+    BLI_cleanup_path(NULL, cleaned);
     res = string(cleaned);
 
     if (!base.empty()) {



More information about the Bf-blender-cvs mailing list