a small change in determining suffix of files
git-svn-id: https://svn.musicpd.org/mpd/trunk@1232 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
1ad2c17ddf
commit
b65ec79c16
24
src/ls.c
24
src/ls.c
@ -149,22 +149,24 @@ int isFile(char * utf8file, time_t * mtime) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hasSuffix(char * utf8file, char * suffix) {
|
/* suffixes should be ascii only characters */
|
||||||
char * file = utf8ToFsCharset(utf8file);
|
char * getSuffix(char * utf8file) {
|
||||||
char * dup = strdup(file);
|
char * ret = NULL;
|
||||||
char * cLast;
|
|
||||||
char * cNext;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
cNext = cLast = strtok(dup,".");
|
while(*utf8file) {
|
||||||
|
if(*utf8file == '.') ret = utf8file+1;
|
||||||
while((cNext = strtok(NULL,"."))) cLast = cNext;
|
utf8file++;
|
||||||
if(cLast && 0==strcasecmp(cLast,suffix)) ret = 1;
|
}
|
||||||
free(dup);
|
|
||||||
|
|
||||||
return ret;
|
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) {
|
int isPlaylist(char * utf8file) {
|
||||||
if(isFile(utf8file,NULL)) {
|
if(isFile(utf8file,NULL)) {
|
||||||
return hasSuffix(utf8file,PLAYLIST_FILE_SUFFIX);
|
return hasSuffix(utf8file,PLAYLIST_FILE_SUFFIX);
|
||||||
|
Loading…
Reference in New Issue
Block a user