From c2dcb67bc750218fbd5e162d8a2f63da9a0e2f98 Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Tue, 4 Nov 2003 23:00:36 +0000 Subject: [PATCH] fix dir scanning --- src/db-memory.c | 5 ++++- src/mp3-scanner.c | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/db-memory.c b/src/db-memory.c index f60fe79d..9bc4f55d 100644 --- a/src/db-memory.c +++ b/src/db-memory.c @@ -20,10 +20,13 @@ */ #include -#include #include #include + +#define __USE_UNIX98 +#include + #include "err.h" #include "mp3-scanner.h" diff --git a/src/mp3-scanner.c b/src/mp3-scanner.c index 0635e03c..d5ecfc97 100644 --- a/src/mp3-scanner.c +++ b/src/mp3-scanner.c @@ -20,6 +20,7 @@ */ #include +#include #include #include #include @@ -58,7 +59,7 @@ int scan_init(char *path) { return -1; } else { /* do deferred updating */ - return ENOTIMPL; + return ENOTSUP; } return 0; @@ -71,7 +72,7 @@ int scan_init(char *path) { */ int scan_foreground(char *path) { MP3FILE mp3file; - DIR *current; + DIR *current_dir; struct dirent de; struct dirent *pde; int err; @@ -85,7 +86,7 @@ int scan_foreground(char *path) { err=readdir_r(current_dir,&de,&pde); if(err == -1) { err=errno; - closedir(current); + closedir(current_dir); errno=err; return -1; } @@ -94,19 +95,19 @@ int scan_foreground(char *path) { break; /* process the file */ - if(de.d_namelen > 4) { - if(strcasecmp(".mp3",de.d_name[de.d_namelen - 4]) == 0) { + if(strlen(de.d_name) > 4) { + if(strcasecmp(".mp3",de.d_name[strlen(de.d_name) - 4]) == 0) { /* we found an mp3 file */ sprintf(mp3_path,"%s/%s",path,de.d_name); - memset(mp3file,0,sizeof(mp3file)); - mp3file->path=mp3_path; - mp3file->fname=de.d_name; + memset((void*)&mp3file,0,sizeof(mp3file)); + mp3file.path=mp3_path; + mp3file.fname=de.d_name; db_add(&mp3file); } } } - closedir(current); + closedir(current_dir); }