diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-04-24 03:01:50 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-04-24 03:01:50 +0400 |
commit | 394537715d1988056fe47a1c3a0dace6d39499e5 (patch) | |
tree | a08cfc13b69fa59d2bcd84cf4393729e8d7edc3d /source/blender/blenlib/intern | |
parent | edc56fae1830047218d2d1d6538765ae02806d7e (diff) |
string number decoding didnt check for win32 slash & minor adjustments to some other path funcs (no functional change).
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 16de81de897..84868915e6b 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -80,7 +80,7 @@ static int add_win32_extension(char *name); /* implementation */ -int BLI_stringdec(char *string, char *head, char *start, unsigned short *numlen) +int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *numlen) { unsigned short len, len2, lenlslash = 0, nums = 0, nume = 0; short i, found = 0; @@ -108,7 +108,7 @@ int BLI_stringdec(char *string, char *head, char *start, unsigned short *numlen) } } if (found){ - if (start) strcpy(start,&string[nume+1]); + if (tail) strcpy(tail, &string[nume+1]); if (head) { strcpy(head,string); head[nums]=0; @@ -116,22 +116,22 @@ int BLI_stringdec(char *string, char *head, char *start, unsigned short *numlen) if (numlen) *numlen = nume-nums+1; return ((int)atoi(&(string[nums]))); } - if (start) strcpy(start, string + len); + if (tail) strcpy(tail, string + len); if (head) { strncpy(head, string, len); - head[len] = 0; + head[len] = '\0'; } if (numlen) *numlen=0; return 0; } -void BLI_stringenc(char *string, char *head, char *start, unsigned short numlen, int pic) +void BLI_stringenc(char *string, const char *head, const char *tail, unsigned short numlen, int pic) { char fmtstr[16]=""; if(pic < 0) pic= 0; sprintf(fmtstr, "%%s%%.%dd%%s", numlen); - sprintf(string, fmtstr, head, pic, start); + sprintf(string, fmtstr, head, pic, tail); } @@ -1109,10 +1109,7 @@ int BLI_testextensie(const char *str, const char *ext) return (retval); } -/* - * This is a simple version of BLI_split_dirfile that has the following advantages... - * - * Converts "/foo/bar.txt" to "/foo/" and "bar.txt" +/* Converts "/foo/bar.txt" to "/foo/" and "bar.txt" * - wont change 'string' * - wont create any directories * - dosnt use CWD, or deal with relative paths. @@ -1120,14 +1117,12 @@ int BLI_testextensie(const char *str, const char *ext) * */ void BLI_split_dirfile(const char *string, char *dir, char *file) { - int lslash=0, i = 0; - for (i=0; string[i]!='\0'; i++) { - if (string[i]=='\\' || string[i]=='/') - lslash = i+1; - } + char *lslash_str = BLI_last_slash(string); + int lslash= lslash_str ? (int)(lslash_str - string) + 1 : 0; + if (dir) { if (lslash) { - BLI_strncpy( dir, string, lslash+1); /* +1 to include the slash and the last char */ + BLI_strncpy( dir, string, lslash + 1); /* +1 to include the slash and the last char */ } else { dir[0] = '\0'; } |