aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-06-22 01:04:13 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-06-22 01:04:13 +0000
commit8933f5d416acf1f6ee66965137d1de7a9dc05989 (patch)
treef7bb79e390eceb2708079dafd42a26688ff2f939
parentb01954575694bcdd3dd52872b44eb5ff88e44eed (diff)
downloadmpd-8933f5d416acf1f6ee66965137d1de7a9dc05989.tar.gz
mpd-8933f5d416acf1f6ee66965137d1de7a9dc05989.tar.xz
mpd-8933f5d416acf1f6ee66965137d1de7a9dc05989.zip
only call opendir() once when updating
git-svn-id: https://svn.musicpd.org/mpd/trunk@1608 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/directory.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/directory.c b/src/directory.c
index 28d3135f1..34efa27dd 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -338,8 +338,7 @@ int updateInDirectory(Directory * directory, char * shortname, char * name) {
0 -> no error, but nothing removed
1 -> no error, and stuff removed
*/
-int removeDeletedFromDirectory(Directory * directory) {
- DIR * dir;
+int removeDeletedFromDirectory(Directory * directory, DIR * dir) {
char cwd[2];
struct dirent * ent;
char * dirname = directory->utf8name;
@@ -355,8 +354,6 @@ int removeDeletedFromDirectory(Directory * directory) {
cwd[1] = '\0';
if(dirname==NULL) dirname=cwd;
- if((dir = opendir(rmp2amp(utf8ToFsCharset(dirname))))==NULL) return -1;
-
while((ent = readdir(dir))) {
if(ent->d_name[0]=='.') continue; /* hide hidden stuff */
if(strchr(ent->d_name, '\n')) continue;
@@ -373,8 +370,6 @@ int removeDeletedFromDirectory(Directory * directory) {
insertInList(entList,utf8,s);
}
- closedir(dir);
-
node = directory->subDirectories->firstNode;
while(node) {
tmpNode = node->nextNode;
@@ -556,10 +551,12 @@ int updateDirectory(Directory * directory) {
cwd[1] = '\0';
if(dirname==NULL) dirname=cwd;
- if(removeDeletedFromDirectory(directory)>0) ret = 1;
-
if((dir = opendir(rmp2amp(utf8ToFsCharset(dirname))))==NULL) return -1;
+ if(removeDeletedFromDirectory(directory, dir)>0) ret = 1;
+
+ rewinddir(dir);
+
while((ent = readdir(dir))) {
if(ent->d_name[0]=='.') continue; /* hide hidden stuff */
if(strchr(ent->d_name, '\n')) continue;