Commit 17f207ff authored by Max Kellermann's avatar Max Kellermann

archive/Lookup: return AllocatedPath

parent 476647bf
...@@ -53,7 +53,7 @@ archive_lookup(PathTraitsFS::pointer_type pathname) ...@@ -53,7 +53,7 @@ archive_lookup(PathTraitsFS::pointer_type pathname)
//its a file ? //its a file ?
if (file_info.IsRegular()) { if (file_info.IsRegular()) {
//so the upper should be file //so the upper should be file
return {Path::FromFS(pathname), Path::FromFS(slash + 1)}; return {AllocatedPath::FromFS(pathname), AllocatedPath::FromFS(slash + 1)};
} else { } else {
return {}; return {};
} }
......
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
#ifndef MPD_ARCHIVE_LOOKUP_HXX #ifndef MPD_ARCHIVE_LOOKUP_HXX
#define MPD_ARCHIVE_LOOKUP_HXX #define MPD_ARCHIVE_LOOKUP_HXX
#include "fs/Path.hxx" #include "fs/AllocatedPath.hxx"
struct ArchiveLookupResult { struct ArchiveLookupResult {
Path archive = nullptr; AllocatedPath archive = nullptr;
Path inside = nullptr; AllocatedPath inside = nullptr;
constexpr operator bool() const noexcept { operator bool() const noexcept {
return !archive.IsNull(); return !archive.IsNull();
} }
}; };
......
...@@ -29,7 +29,6 @@ TEST(ArchiveTest, Lookup) ...@@ -29,7 +29,6 @@ TEST(ArchiveTest, Lookup)
path = strdup("dummy/foo/bar"); path = strdup("dummy/foo/bar");
auto result = archive_lookup(path); auto result = archive_lookup(path);
EXPECT_TRUE(result); EXPECT_TRUE(result);
EXPECT_EQ((const char *)path, result.archive.c_str());
EXPECT_STREQ(result.archive.c_str(), "dummy"); EXPECT_STREQ(result.archive.c_str(), "dummy");
EXPECT_STREQ(result.inside.c_str(), "foo/bar"); EXPECT_STREQ(result.inside.c_str(), "foo/bar");
free(path); free(path);
...@@ -37,7 +36,6 @@ TEST(ArchiveTest, Lookup) ...@@ -37,7 +36,6 @@ TEST(ArchiveTest, Lookup)
path = strdup("config.h/foo/bar"); path = strdup("config.h/foo/bar");
result = archive_lookup(path); result = archive_lookup(path);
EXPECT_TRUE(result); EXPECT_TRUE(result);
EXPECT_EQ((const char *)path, result.archive.c_str());
EXPECT_STREQ(result.archive.c_str(), "config.h"); EXPECT_STREQ(result.archive.c_str(), "config.h");
EXPECT_STREQ(result.inside.c_str(), "foo/bar"); EXPECT_STREQ(result.inside.c_str(), "foo/bar");
free(path); free(path);
......
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