mirror of
https://github.com/owntone/owntone-server.git
synced 2025-03-31 01:33:44 -04:00
fix dir scanning
This commit is contained in:
parent
621d18135e
commit
c2dcb67bc7
@ -20,10 +20,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define __USE_UNIX98
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
#include "mp3-scanner.h"
|
#include "mp3-scanner.h"
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -58,7 +59,7 @@ int scan_init(char *path) {
|
|||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
/* do deferred updating */
|
/* do deferred updating */
|
||||||
return ENOTIMPL;
|
return ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -71,7 +72,7 @@ int scan_init(char *path) {
|
|||||||
*/
|
*/
|
||||||
int scan_foreground(char *path) {
|
int scan_foreground(char *path) {
|
||||||
MP3FILE mp3file;
|
MP3FILE mp3file;
|
||||||
DIR *current;
|
DIR *current_dir;
|
||||||
struct dirent de;
|
struct dirent de;
|
||||||
struct dirent *pde;
|
struct dirent *pde;
|
||||||
int err;
|
int err;
|
||||||
@ -85,7 +86,7 @@ int scan_foreground(char *path) {
|
|||||||
err=readdir_r(current_dir,&de,&pde);
|
err=readdir_r(current_dir,&de,&pde);
|
||||||
if(err == -1) {
|
if(err == -1) {
|
||||||
err=errno;
|
err=errno;
|
||||||
closedir(current);
|
closedir(current_dir);
|
||||||
errno=err;
|
errno=err;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -94,19 +95,19 @@ int scan_foreground(char *path) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* process the file */
|
/* process the file */
|
||||||
if(de.d_namelen > 4) {
|
if(strlen(de.d_name) > 4) {
|
||||||
if(strcasecmp(".mp3",de.d_name[de.d_namelen - 4]) == 0) {
|
if(strcasecmp(".mp3",de.d_name[strlen(de.d_name) - 4]) == 0) {
|
||||||
/* we found an mp3 file */
|
/* we found an mp3 file */
|
||||||
sprintf(mp3_path,"%s/%s",path,de.d_name);
|
sprintf(mp3_path,"%s/%s",path,de.d_name);
|
||||||
memset(mp3file,0,sizeof(mp3file));
|
memset((void*)&mp3file,0,sizeof(mp3file));
|
||||||
mp3file->path=mp3_path;
|
mp3file.path=mp3_path;
|
||||||
mp3file->fname=de.d_name;
|
mp3file.fname=de.d_name;
|
||||||
|
|
||||||
db_add(&mp3file);
|
db_add(&mp3file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(current);
|
closedir(current_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user