diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/directory.c | 13 |
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; |