diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-01-31 01:33:47 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-01-31 01:33:47 +0300 |
commit | f749d0361f8a2cf8ba7d515c31cec1dcf8fe96a5 (patch) | |
tree | 6a510ba82bba9795faf1ffacf53e529dd0e4e196 /source/blender/blenlib/intern/path_util.c | |
parent | 1943a73439f04f65d721c8e58270d29498ff6b96 (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/intern/path_util.c')
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 29 |
1 files changed, 27 insertions, 2 deletions
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" */ |