diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-02-17 16:43:50 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-02-17 16:43:50 +0300 |
commit | 712e8c6a5c0173ccf251060c4e018ac81b6ae916 (patch) | |
tree | 37de80e00d00a7d013daa2837ee75b6ee1db1f08 /source/blender/blenlib | |
parent | b9da824821a8ba3edce214f1573e9299ec0dd72a (diff) |
fix for negative frames messing up image sequence name.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 74 |
1 files changed, 21 insertions, 53 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 2703de13bd3..1bf321ec1bc 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -97,41 +97,19 @@ static int add_win32_extension(char *name); /* implementation */ -int BLI_stringdec(char *string, char *kop, char *start, unsigned short *numlen) +int BLI_stringdec(char *string, char *head, char *start, unsigned short *numlen) { - unsigned short len, len2, nums = 0, nume = 0; + unsigned short len, len2, lenlslash = 0, nums = 0, nume = 0; short i, found = 0; - + char *lslash = BLI_last_slash(string); len2 = len = strlen(string); - - if (len > 6) { - if (BLI_strncasecmp(string + len - 6, ".blend", 6) == 0) len -= 6; - else if (BLI_strncasecmp(string + len - 6, ".trace", 6) == 0) len -= 6; - } - - if (len > 9) { - if (BLI_strncasecmp(string + len - 9, ".blend.gz", 9) == 0) len -= 9; - } - - if (len == len2) { - if (len > 4) { - /* handle .jf0 en .jf1 for jstreams */ - if (BLI_strncasecmp(string + len - 4, ".jf", 3) == 0) len -= 4; - else if (BLI_strncasecmp(string + len - 4, ".tga", 4) == 0) len -= 4; - else if (BLI_strncasecmp(string + len - 4, ".jpg", 4) == 0) len -= 4; - else if (BLI_strncasecmp(string + len - 4, ".png", 4) == 0) len -= 4; - else if (BLI_strncasecmp(string + len - 4, ".txt", 4) == 0) len -= 4; - else if (BLI_strncasecmp(string + len - 4, ".cyc", 4) == 0) len -= 4; - else if (BLI_strncasecmp(string + len - 4, ".enh", 4) == 0) len -= 4; - else if (BLI_strncasecmp(string + len - 4, ".rgb", 4) == 0) len -= 4; - else if (BLI_strncasecmp(string + len - 4, ".psx", 4) == 0) len -= 4; - else if (BLI_strncasecmp(string + len - 4, ".ble", 4) == 0) len -= 4; - else if (BLI_strncasecmp(string + len - 4, ".exr", 4) == 0) len -= 4; - } - } - - for (i = len - 1; i >= 0; i--) { - if (string[i] == '/') break; + if(lslash) + lenlslash= (int)(lslash - string); + + while(len > lenlslash && string[--len] != '.') {}; + if(len == lenlslash && string[len] != '.') len = len2; + + for (i = len - 1; i >= lenlslash; i--) { if (isdigit(string[i])) { if (found){ nums = i; @@ -148,39 +126,29 @@ int BLI_stringdec(char *string, char *kop, char *start, unsigned short *numlen) } if (found){ if (start) strcpy(start,&string[nume+1]); - if (kop) { - strcpy(kop,string); - kop[nums]=0; + if (head) { + strcpy(head,string); + head[nums]=0; } if (numlen) *numlen = nume-nums+1; return ((int)atoi(&(string[nums]))); } if (start) strcpy(start, string + len); - if (kop) { - strncpy(kop, string, len); - kop[len] = 0; + if (head) { + strncpy(head, string, len); + head[len] = 0; } if (numlen) *numlen=0; return 0; } -void BLI_stringenc(char *string, char *kop, char *start, unsigned short numlen, int pic) +void BLI_stringenc(char *string, char *head, char *start, unsigned short numlen, int pic) { - char numstr[10]=""; - unsigned short len,i; - - strcpy(string,kop); - - if (pic>0 || numlen==4) { - len= sprintf(numstr,"%d",pic); - - for(i=len;i<numlen;i++){ - strcat(string,"0"); - } - strcat(string,numstr); - } - strcat(string, start); + char fmtstr[16]=""; + if(pic < 0) pic= 0; + sprintf(fmtstr, "%%s%%.%dd%%s", numlen); + sprintf(string, fmtstr, head, pic, start); } |