From fcf641596322d6d51176593fe3df8d16b8f29934 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 15 Jun 2019 14:06:50 +0200 Subject: [PATCH] archive/Lookup: pass class Path --- src/archive/ArchiveLookup.cxx | 6 ++---- src/archive/ArchiveLookup.hxx | 2 +- src/input/plugins/ArchiveInputPlugin.cxx | 2 +- test/test_archive.cxx | 12 ++++++------ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/archive/ArchiveLookup.cxx b/src/archive/ArchiveLookup.cxx index 5ec0abcd2..e9227c913 100644 --- a/src/archive/ArchiveLookup.cxx +++ b/src/archive/ArchiveLookup.cxx @@ -21,8 +21,6 @@ #include "fs/FileInfo.hxx" #include "system/Error.hxx" -#include - gcc_pure static PathTraitsFS::pointer_type FindSlash(PathTraitsFS::pointer_type p, size_t i) noexcept @@ -35,9 +33,9 @@ FindSlash(PathTraitsFS::pointer_type p, size_t i) noexcept } ArchiveLookupResult -archive_lookup(PathTraitsFS::const_pointer_type pathname) +archive_lookup(Path pathname) { - PathTraitsFS::string buffer(pathname); + PathTraitsFS::string buffer(pathname.c_str()); size_t idx = buffer.size(); PathTraitsFS::pointer_type slash = nullptr; diff --git a/src/archive/ArchiveLookup.hxx b/src/archive/ArchiveLookup.hxx index 567ca1bb4..6166dd3ca 100644 --- a/src/archive/ArchiveLookup.hxx +++ b/src/archive/ArchiveLookup.hxx @@ -50,7 +50,7 @@ struct ArchiveLookupResult { * Throws on error. */ ArchiveLookupResult -archive_lookup(PathTraitsFS::const_pointer_type pathname); +archive_lookup(Path pathname); #endif diff --git a/src/input/plugins/ArchiveInputPlugin.cxx b/src/input/plugins/ArchiveInputPlugin.cxx index d4bf86544..769b67c58 100644 --- a/src/input/plugins/ArchiveInputPlugin.cxx +++ b/src/input/plugins/ArchiveInputPlugin.cxx @@ -34,7 +34,7 @@ OpenArchiveInputStream(Path path, Mutex &mutex) // archive_lookup will modify pname when true is returned ArchiveLookupResult l; try { - l = archive_lookup(path.c_str()); + l = archive_lookup(path); if (l.archive.IsNull()) { return nullptr; } diff --git a/test/test_archive.cxx b/test/test_archive.cxx index ff3a93314..55e655b21 100644 --- a/test/test_archive.cxx +++ b/test/test_archive.cxx @@ -8,22 +8,22 @@ TEST(ArchiveTest, Lookup) { - EXPECT_THROW(archive_lookup(""), std::system_error); + EXPECT_THROW(archive_lookup(Path::FromFS("")), std::system_error); - EXPECT_FALSE(archive_lookup(".")); + EXPECT_FALSE(archive_lookup(Path::FromFS("."))); - EXPECT_FALSE(archive_lookup("config.h")); + EXPECT_FALSE(archive_lookup(Path::FromFS("config.h"))); - EXPECT_THROW(archive_lookup("src/foo/bar"), std::system_error); + EXPECT_THROW(archive_lookup(Path::FromFS("src/foo/bar")), std::system_error); fclose(fopen("dummy", "w")); - auto result = archive_lookup("dummy/foo/bar"); + auto result = archive_lookup(Path::FromFS("dummy/foo/bar")); EXPECT_TRUE(result); EXPECT_STREQ(result.archive.c_str(), "dummy"); EXPECT_STREQ(result.inside.c_str(), "foo/bar"); - result = archive_lookup("config.h/foo/bar"); + result = archive_lookup(Path::FromFS("config.h/foo/bar")); EXPECT_TRUE(result); EXPECT_STREQ(result.archive.c_str(), "config.h"); EXPECT_STREQ(result.inside.c_str(), "foo/bar");