aboutsummaryrefslogtreecommitdiffstats
path: root/src/UpdateArchive.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-29 21:21:07 +0100
committerMax Kellermann <max@duempel.org>2013-01-29 21:21:07 +0100
commit9f0fb8f6a8f58ff9a760d40bccfadd010b9ddef9 (patch)
treee8f5dc8f9e19cfb0873b2f761e26b8a9da7b5e36 /src/UpdateArchive.cxx
parenta42f9fd4e2ccb164c0634571da9903e6a2aa507a (diff)
downloadmpd-9f0fb8f6a8f58ff9a760d40bccfadd010b9ddef9.tar.gz
mpd-9f0fb8f6a8f58ff9a760d40bccfadd010b9ddef9.tar.xz
mpd-9f0fb8f6a8f58ff9a760d40bccfadd010b9ddef9.zip
ArchivePlugin: replace scan_reset(), scan_next() with visit()
Add the interface ArchiveVisitor.
Diffstat (limited to 'src/UpdateArchive.cxx')
-rw-r--r--src/UpdateArchive.cxx22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/UpdateArchive.cxx b/src/UpdateArchive.cxx
index 5da212e9d..88d67fbc0 100644
--- a/src/UpdateArchive.cxx
+++ b/src/UpdateArchive.cxx
@@ -27,6 +27,7 @@
#include "fs/Path.hxx"
#include "ArchiveList.hxx"
#include "ArchivePlugin.hxx"
+#include "ArchiveVisitor.hxx"
#include <glib.h>
@@ -122,14 +123,21 @@ update_archive_file2(Directory *parent, const char *name,
directory->mtime = st->st_mtime;
- archive_file_scan_reset(file);
+ class UpdateArchiveVisitor final : public ArchiveVisitor {
+ Directory *directory;
- const char *filepath;
- while ((filepath = archive_file_scan_next(file)) != NULL) {
- /* split name into directory and file */
- g_debug("adding archive file: %s", filepath);
- update_archive_tree(directory, filepath);
- }
+ public:
+ UpdateArchiveVisitor(Directory *_directory)
+ :directory(_directory) {}
+
+ virtual void VisitArchiveEntry(const char *path_utf8) override {
+ g_debug("adding archive file: %s", path_utf8);
+ update_archive_tree(directory, path_utf8);
+ }
+ };
+
+ UpdateArchiveVisitor visitor(directory);
+ archive_file_visit(file, visitor);
archive_file_close(file);
}