aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-06-22 00:55:23 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-06-22 00:55:23 +0000
commitb01954575694bcdd3dd52872b44eb5ff88e44eed (patch)
treedc94fa612a54588ad20e42d346c7539e2fbbfbb9
parentd7a56bb18c0286d2416834fd9fdccb59fca9e9d5 (diff)
downloadmpd-b01954575694bcdd3dd52872b44eb5ff88e44eed.tar.gz
mpd-b01954575694bcdd3dd52872b44eb5ff88e44eed.tar.xz
mpd-b01954575694bcdd3dd52872b44eb5ff88e44eed.zip
call stat() a few less times on update
git-svn-id: https://svn.musicpd.org/mpd/trunk@1607 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/directory.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/directory.c b/src/directory.c
index a05553dd6..28d3135f1 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -301,16 +301,18 @@ void deleteEmptyDirectoriesInDirectory(Directory * directory) {
1 -> no error, and stuff updated
*/
int updateInDirectory(Directory * directory, char * shortname, char * name) {
- time_t mtime;
void * song;
void * subDir;
+ struct stat st;
+
+ if(myStat(name, &st)) return -1;
- if(isMusic(name,&mtime)) {
+ if(S_ISREG(st.st_mode) && hasMusicSuffix(name)) {
if(0==findInList(directory->songs,shortname,&song)) {
addToDirectory(directory,shortname,name);
return DIRECTORY_RETURN_UPDATE;
}
- else if(mtime!=((Song *)song)->mtime) {
+ else if(st.st_mtime!=((Song *)song)->mtime) {
LOG("updating %s\n",name);
if(updateSongInfo((Song *)song)<0) {
removeSongFromDirectory(directory,shortname);
@@ -318,7 +320,7 @@ int updateInDirectory(Directory * directory, char * shortname, char * name) {
return 1;
}
}
- else if(isDir(name)) {
+ else if(S_ISDIR(st.st_mode)) {
if(findInList(directory->subDirectories,shortname,(void **)&subDir)) {
if(updateDirectory((Directory *)subDir)>0) return 1;
}
@@ -648,10 +650,11 @@ int addSubDirectoryToDirectory(Directory * directory, char * shortname,
}
int addToDirectory(Directory * directory, char * shortname, char * name) {
- if(isDir(name)) {
- return addSubDirectoryToDirectory(directory,shortname,name);
- }
- else if(isMusic(name,NULL)) {
+ struct stat st;
+
+ if(myStat(name, &st)) return -1;
+
+ if(S_ISREG(st.st_mode) && hasMusicSuffix(name)) {
Song * song;
song = addSongToList(directory->songs,shortname,name,
SONG_TYPE_FILE);
@@ -659,6 +662,9 @@ int addToDirectory(Directory * directory, char * shortname, char * name) {
LOG("added %s\n",name);
return 1;
}
+ else if(S_ISDIR(st.st_mode)) {
+ return addSubDirectoryToDirectory(directory,shortname,name);
+ }
DEBUG("addToDirectory: %s is not a directory or music\n",name);