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:
Diffstat (limited to 'source/blender/blenlib/intern/path_util.c')
-rw-r--r--source/blender/blenlib/intern/path_util.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index c1f6cc4b49a..9f16b604432 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -912,7 +912,7 @@ bool BLI_path_frame_get(char *path, int *r_frame, int *r_numdigits)
return false;
}
-void BLI_path_frame_strip(char *path, bool setsharp, char *ext)
+bool BLI_path_frame_strip(char *path, bool setsharp, char *ext)
{
if (path && *path) {
char *file = (char *)BLI_last_slash(path);
@@ -946,20 +946,41 @@ void BLI_path_frame_strip(char *path, bool setsharp, char *ext)
c++;
- if (numdigits) {
- /* replace the number with the suffix and terminate the string */
- while (numdigits--) {
- if (ext) *ext++ = *suffix;
-
- if (setsharp) *c++ = '#';
- else *c++ = *suffix;
+ if(numdigits) {
+ /* logic here is a bit complex. Idea is: if ext has been provided,
+ * fill it with the extension part and do not keep it in filename
+ * if no ext has been provided, just strip the number or fill it with #
+ */
+ if (ext) {
+ while (*suffix) {
+ *ext++ = *suffix++;
+ }
+ *ext = 0;
- suffix++;
+ if (setsharp) {
+ while (numdigits--) {
+ *c++ = '#';
+ }
+ }
+ *c = 0;
}
- *c = 0;
- if (ext) *ext = 0;
+ else {
+ if (setsharp) {
+ while (numdigits--) {
+ *c++ = '#';
+ }
+ }
+ while (*suffix) {
+ *c++ = *suffix++;
+ }
+ *c = 0;
+ }
+
+ return true;
}
}
+
+ return false;
}