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>2010-01-31 01:33:47 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-01-31 01:33:47 +0300
commitf749d0361f8a2cf8ba7d515c31cec1dcf8fe96a5 (patch)
tree6a510ba82bba9795faf1ffacf53e529dd0e4e196 /source/blender/blenlib
parent1943a73439f04f65d721c8e58270d29498ff6b96 (diff)
- hash characters in the path would confuse the output file name and not add numbers to it (when rendering animations).
- added an option to BLI_convertstringframe and BLI_convertstringframe_range to add digits if not found. - removed BLI_convertstringframe where its obviously not needed - such as loading movies and sounds.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_path_util.h4
-rw-r--r--source/blender/blenlib/intern/path_util.c29
2 files changed, 29 insertions, 4 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index f9ef3d8c828..8e97511f4c5 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -97,8 +97,8 @@ int BLI_has_parent(char *path);
* @retval Returns true if the path was relative (started with "//").
*/
int BLI_convertstringcode(char *path, const char *basepath);
-int BLI_convertstringframe(char *path, int frame);
-int BLI_convertstringframe_range(char *path, int sta, int end);
+int BLI_convertstringframe(char *path, int frame, int digits);
+int BLI_convertstringframe_range(char *path, int sta, int end, int digits);
int BLI_convertstringcwd(char *path);
void BLI_makestringcode(const char *relfile, char *file);
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 895f2d1ee56..c3ce73df6c6 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -557,9 +557,30 @@ static int stringframe_chars(char *path, int *char_start, int *char_end)
}
}
-int BLI_convertstringframe(char *path, int frame)
+static void ensure_digits(char *path, int digits)
+{
+ char *file= BLI_last_slash(path);
+
+ if(file==NULL)
+ file= path;
+
+ if(strrchr(file, '#') == NULL) {
+ int len= strlen(file);
+
+ while(digits--) {
+ file[len++]= '#';
+ }
+ file[len]= '\0';
+ }
+}
+
+int BLI_convertstringframe(char *path, int frame, int digits)
{
int ch_sta, ch_end;
+
+ if(digits)
+ ensure_digits(path, digits);
+
if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */
char tmp[FILE_MAX], format[64];
sprintf(format, "%%.%ds%%.%dd%%s", ch_sta, ch_end-ch_sta); /* example result: "%.12s%.5d%s" */
@@ -570,9 +591,13 @@ int BLI_convertstringframe(char *path, int frame)
return 0;
}
-int BLI_convertstringframe_range(char *path, int sta, int end)
+int BLI_convertstringframe_range(char *path, int sta, int end, int digits)
{
int ch_sta, ch_end;
+
+ if(digits)
+ ensure_digits(path, digits);
+
if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */
char tmp[FILE_MAX], format[64];
sprintf(format, "%%.%ds%%.%dd_%%.%dd%%s", ch_sta, ch_end-ch_sta, ch_end-ch_sta); /* example result: "%.12s%.5d-%.5d%s" */