diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-05-30 00:05:23 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-05-30 00:05:23 +0000 |
commit | b65ec79c1651b10a3f5ce4fe21bbd2f829fff72a (patch) | |
tree | 81a55306f9cfa741336cb9a332248ae1abe9e64c /src | |
parent | 1ad2c17ddf8ceab2b5966bac6ca3583f0b6d1848 (diff) | |
download | mpd-b65ec79c1651b10a3f5ce4fe21bbd2f829fff72a.tar.gz mpd-b65ec79c1651b10a3f5ce4fe21bbd2f829fff72a.tar.xz mpd-b65ec79c1651b10a3f5ce4fe21bbd2f829fff72a.zip |
a small change in determining suffix of files
git-svn-id: https://svn.musicpd.org/mpd/trunk@1232 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/ls.c | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -149,22 +149,24 @@ int isFile(char * utf8file, time_t * mtime) { return 0; } -int hasSuffix(char * utf8file, char * suffix) { - char * file = utf8ToFsCharset(utf8file); - char * dup = strdup(file); - char * cLast; - char * cNext; - int ret = 0; - - cNext = cLast = strtok(dup,"."); - - while((cNext = strtok(NULL,"."))) cLast = cNext; - if(cLast && 0==strcasecmp(cLast,suffix)) ret = 1; - free(dup); +/* suffixes should be ascii only characters */ +char * getSuffix(char * utf8file) { + char * ret = NULL; + + while(*utf8file) { + if(*utf8file == '.') ret = utf8file+1; + utf8file++; + } return ret; } +int hasSuffix(char * utf8file, char * suffix) { + char * s = getSuffix(utf8file); + if(s && 0==strcmp(s,suffix)) return 1; + return 0; +} + int isPlaylist(char * utf8file) { if(isFile(utf8file,NULL)) { return hasSuffix(utf8file,PLAYLIST_FILE_SUFFIX); |