summaryrefslogtreecommitdiff
path: root/src/archive
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-08 13:21:50 +0100
committerMax Kellermann <max@duempel.org>2014-02-08 13:25:44 +0100
commitfe7c6fee348a3263ce0c97a83547749725f681cb (patch)
tree9773e269458ed7847fa9d566a20dfdd6db89b59a /src/archive
parent9906daeca71b7e552721f85f3696d9e6a20f7a5b (diff)
ArchivePlugin: pass Path to open()
Diffstat (limited to 'src/archive')
-rw-r--r--src/archive/ArchivePlugin.cxx5
-rw-r--r--src/archive/ArchivePlugin.hxx5
-rw-r--r--src/archive/plugins/Bzip2ArchivePlugin.cxx10
-rw-r--r--src/archive/plugins/Iso9660ArchivePlugin.cxx8
-rw-r--r--src/archive/plugins/ZzipArchivePlugin.cxx7
5 files changed, 21 insertions, 14 deletions
diff --git a/src/archive/ArchivePlugin.cxx b/src/archive/ArchivePlugin.cxx
index 6633c1748..67f469e08 100644
--- a/src/archive/ArchivePlugin.cxx
+++ b/src/archive/ArchivePlugin.cxx
@@ -20,17 +20,18 @@
#include "config.h"
#include "ArchivePlugin.hxx"
#include "ArchiveFile.hxx"
+#include "fs/Path.hxx"
#include "util/Error.hxx"
#include <assert.h>
ArchiveFile *
-archive_file_open(const ArchivePlugin *plugin, const char *path,
+archive_file_open(const ArchivePlugin *plugin, Path path,
Error &error)
{
assert(plugin != nullptr);
assert(plugin->open != nullptr);
- assert(path != nullptr);
+ assert(!path.IsNull());
ArchiveFile *file = plugin->open(path, error);
assert((file == nullptr) == error.IsDefined());
diff --git a/src/archive/ArchivePlugin.hxx b/src/archive/ArchivePlugin.hxx
index 023c933f3..eb24bbdf9 100644
--- a/src/archive/ArchivePlugin.hxx
+++ b/src/archive/ArchivePlugin.hxx
@@ -21,6 +21,7 @@
#define MPD_ARCHIVE_PLUGIN_HXX
class ArchiveFile;
+class Path;
class Error;
struct ArchivePlugin {
@@ -44,7 +45,7 @@ struct ArchivePlugin {
* returns pointer to handle used is all operations with this archive
* or nullptr when opening fails
*/
- ArchiveFile *(*open)(const char *path_fs, Error &error);
+ ArchiveFile *(*open)(Path path_fs, Error &error);
/**
* suffixes handled by this plugin.
@@ -54,7 +55,7 @@ struct ArchivePlugin {
};
ArchiveFile *
-archive_file_open(const ArchivePlugin *plugin, const char *path,
+archive_file_open(const ArchivePlugin *plugin, Path path,
Error &error);
#endif
diff --git a/src/archive/plugins/Bzip2ArchivePlugin.cxx b/src/archive/plugins/Bzip2ArchivePlugin.cxx
index 272a3f81c..8cb9af122 100644
--- a/src/archive/plugins/Bzip2ArchivePlugin.cxx
+++ b/src/archive/plugins/Bzip2ArchivePlugin.cxx
@@ -32,6 +32,7 @@
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "fs/Traits.hxx"
+#include "fs/Path.hxx"
#include <bzlib.h>
@@ -49,9 +50,9 @@ public:
std::string name;
InputStream *const istream;
- Bzip2ArchiveFile(const char *path, InputStream *_is)
+ Bzip2ArchiveFile(Path path, InputStream *_is)
:ArchiveFile(bz2_archive_plugin),
- name(PathTraitsUTF8::GetBase(path)),
+ name(PathTraitsFS::GetBase(path.c_str())),
istream(_is) {
// remove .bz2 suffix
const size_t len = name.length();
@@ -142,11 +143,12 @@ Bzip2InputStream::Close()
/* archive open && listing routine */
static ArchiveFile *
-bz2_open(const char *pathname, Error &error)
+bz2_open(Path pathname, Error &error)
{
static Mutex mutex;
static Cond cond;
- InputStream *is = InputStream::OpenReady(pathname, mutex, cond, error);
+ InputStream *is = InputStream::OpenReady(pathname.c_str(), mutex, cond,
+ error);
if (is == nullptr)
return nullptr;
diff --git a/src/archive/plugins/Iso9660ArchivePlugin.cxx b/src/archive/plugins/Iso9660ArchivePlugin.cxx
index d84cbc2cd..f2f91e9f6 100644
--- a/src/archive/plugins/Iso9660ArchivePlugin.cxx
+++ b/src/archive/plugins/Iso9660ArchivePlugin.cxx
@@ -28,6 +28,7 @@
#include "../ArchiveVisitor.hxx"
#include "input/InputStream.hxx"
#include "input/InputPlugin.hxx"
+#include "fs/Path.hxx"
#include "util/RefCount.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
@@ -117,13 +118,14 @@ Iso9660ArchiveFile::Visit(const char *psz_path, ArchiveVisitor &visitor)
}
static ArchiveFile *
-iso9660_archive_open(const char *pathname, Error &error)
+iso9660_archive_open(Path pathname, Error &error)
{
/* open archive */
- auto iso = iso9660_open(pathname);
+ auto iso = iso9660_open(pathname.c_str());
if (iso == nullptr) {
error.Format(iso9660_domain,
- "Failed to open ISO9660 file %s", pathname);
+ "Failed to open ISO9660 file %s",
+ pathname.c_str());
return nullptr;
}
diff --git a/src/archive/plugins/ZzipArchivePlugin.cxx b/src/archive/plugins/ZzipArchivePlugin.cxx
index 5ae3ace8d..716b56160 100644
--- a/src/archive/plugins/ZzipArchivePlugin.cxx
+++ b/src/archive/plugins/ZzipArchivePlugin.cxx
@@ -28,6 +28,7 @@
#include "../ArchiveVisitor.hxx"
#include "input/InputStream.hxx"
#include "input/InputPlugin.hxx"
+#include "fs/Path.hxx"
#include "util/RefCount.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
@@ -70,12 +71,12 @@ static constexpr Domain zzip_domain("zzip");
/* archive open && listing routine */
static ArchiveFile *
-zzip_archive_open(const char *pathname, Error &error)
+zzip_archive_open(Path pathname, Error &error)
{
- ZZIP_DIR *dir = zzip_dir_open(pathname, nullptr);
+ ZZIP_DIR *dir = zzip_dir_open(pathname.c_str(), nullptr);
if (dir == nullptr) {
error.Format(zzip_domain, "Failed to open ZIP file %s",
- pathname);
+ pathname.c_str());
return nullptr;
}