From bcdc603b40b3e16053d8f67ac4ef89ff0cf4a01a Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Tue, 9 May 2006 05:48:29 +0000 Subject: [PATCH] Make m3u parser recognize windows path separators, as well as windows drive letters. This fixes both bug #104 and #105. --- src/mp3-scanner.c | 6 +++--- src/os-win32.c | 5 +++++ src/os-win32.h | 6 ++++++ src/win32.h | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/mp3-scanner.c b/src/mp3-scanner.c index 2fbb6e70..658b1898 100644 --- a/src/mp3-scanner.c +++ b/src/mp3-scanner.c @@ -404,7 +404,7 @@ int scan_static_playlist(char *path) { return FALSE; } - if((current=strrchr(path,'/')) == NULL) { + if((current=strrchr(path,PATHSEP)) == NULL) { current = path; } else { current++; @@ -442,7 +442,7 @@ int scan_static_playlist(char *path) { } /* now get the *real* base_path */ strcpy(base_path,path); - if((current=strrchr(base_path,'/'))) { + if((current=strrchr(base_path,PATHSEP))) { *(current+1) = '\x0'; } /* else something is fubar */ @@ -460,7 +460,7 @@ int scan_static_playlist(char *path) { // FIXME - should chomp trailing comments // otherwise, assume it is a path - if(linebuffer[0] == '/') { + if((linebuffer[0] == PATHSEP) || (linebuffer[1] == ':')) { strcpy(file_path,linebuffer); } else { snprintf(file_path,sizeof(file_path),"%s%s",base_path,linebuffer); diff --git a/src/os-win32.c b/src/os-win32.c index a1a95843..c97231ac 100644 --- a/src/os-win32.c +++ b/src/os-win32.c @@ -561,6 +561,11 @@ int os_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) { entry->d_namlen - entry->d_namlen % 4; strcpy (entry->d_name, dirp->dir_find_data.cFileName); + entry->d_type = 0; + if(dirp->dir_find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + entry->d_type |= DT_DIR; + } + /* if (dir_is_fat) _strlwr (dir_static.d_name); diff --git a/src/os-win32.h b/src/os-win32.h index e7f31a17..bc986c9b 100644 --- a/src/os-win32.h +++ b/src/os-win32.h @@ -20,11 +20,17 @@ struct timezone { int tz_dsttime; }; +#define DT_DIR 1 + +#define W_OK 2 +#define R_OK 4 + struct dirent { /* data from readdir() */ long d_ino; /* inode number of entry */ unsigned short d_reclen; /* length of this record */ unsigned short d_namlen; /* length of string in d_name */ + int d_type; /* flags */ char d_name[MAXNAMLEN+1]; /* name of file */ }; diff --git a/src/win32.h b/src/win32.h index a14f101a..898f60f3 100644 --- a/src/win32.h +++ b/src/win32.h @@ -34,6 +34,7 @@ #define popen _popen #define pclose _pclose #define strtoll strtol +#define access _access #define realpath os_realpath #define close os_close