Commit fcf64159 authored by Max Kellermann's avatar Max Kellermann

archive/Lookup: pass class Path

parent be79b44d
......@@ -21,8 +21,6 @@
#include "fs/FileInfo.hxx"
#include "system/Error.hxx"
#include <string.h>
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;
......
......@@ -50,7 +50,7 @@ struct ArchiveLookupResult {
* Throws on error.
*/
ArchiveLookupResult
archive_lookup(PathTraitsFS::const_pointer_type pathname);
archive_lookup(Path pathname);
#endif
......@@ -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;
}
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment