remove empty directories
git-svn-id: https://svn.musicpd.org/mpd/trunk@233 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
8d95265cc8
commit
e129640141
|
@ -76,6 +76,8 @@ int exploreDirectory(Directory * directory);
|
|||
|
||||
int updateDirectory(Directory * directory);
|
||||
|
||||
void deleteEmptyDirectoriesInDirectory(Directory * directory);
|
||||
|
||||
int addSubDirectoryToDirectory(Directory * directory, char * shortname, char * name);
|
||||
|
||||
Directory * newDirectory(Directory * parentDirectory, char * dirname, time_t mtime) {
|
||||
|
@ -121,6 +123,24 @@ void removeSongFromDirectory(Directory * directory, char * shortname) {
|
|||
}
|
||||
}
|
||||
|
||||
void deleteEmptyDirectoriesInDirectory(Directory * directory) {
|
||||
ListNode * node = directory->subDirectories->firstNode;
|
||||
ListNode * nextNode;
|
||||
Directory * subDir;
|
||||
|
||||
while(node) {
|
||||
subDir = (Directory *)node->data;
|
||||
deleteEmptyDirectoriesInDirectory(subDir);
|
||||
nextNode = node->nextNode;
|
||||
if(subDir->subDirectories->numberOfNodes==0 &&
|
||||
subDir->songs->numberOfNodes==0)
|
||||
{
|
||||
deleteNodeFromList(directory->subDirectories,node);
|
||||
}
|
||||
node = nextNode;
|
||||
}
|
||||
}
|
||||
|
||||
int updateInDirectory(Directory * directory, char * shortname, char * name) {
|
||||
time_t mtime;
|
||||
void * song;
|
||||
|
@ -475,6 +495,7 @@ void sortDirectory(Directory * directory) {
|
|||
int writeDirectoryDB() {
|
||||
FILE * fp;
|
||||
|
||||
deleteEmptyDirectoriesInDirectory(mp3rootDirectory);
|
||||
sortDirectory(mp3rootDirectory);
|
||||
stats.numberOfSongs = countSongsIn(stderr,NULL);
|
||||
stats.dbPlayTime = sumSongTimesIn(stderr,NULL);
|
||||
|
|
Loading…
Reference in New Issue