Merge branch 'v0.22.x'

This commit is contained in:
Max Kellermann
2021-03-05 16:05:56 +01:00
13 changed files with 142 additions and 74 deletions

View File

@@ -8,23 +8,23 @@
TEST(ArchiveTest, Lookup)
{
EXPECT_THROW(LookupFile(Path::FromFS("")), std::system_error);
EXPECT_THROW(LookupFile(Path::FromFS(PATH_LITERAL(""))), std::system_error);
EXPECT_FALSE(LookupFile(Path::FromFS(".")));
EXPECT_FALSE(LookupFile(Path::FromFS(PATH_LITERAL("."))));
EXPECT_FALSE(LookupFile(Path::FromFS("config.h")));
EXPECT_FALSE(LookupFile(Path::FromFS(PATH_LITERAL("config.h"))));
EXPECT_THROW(LookupFile(Path::FromFS("src/foo/bar")), std::system_error);
EXPECT_THROW(LookupFile(Path::FromFS(PATH_LITERAL("src/foo/bar"))), std::system_error);
fclose(fopen("dummy", "w"));
auto result = LookupFile(Path::FromFS("dummy/foo/bar"));
auto result = LookupFile(Path::FromFS(PATH_LITERAL("dummy/foo/bar")));
EXPECT_TRUE(result);
EXPECT_STREQ(result.archive.c_str(), "dummy");
EXPECT_STREQ(result.inside.c_str(), "foo/bar");
EXPECT_STREQ(result.archive.c_str(), PATH_LITERAL("dummy"));
EXPECT_STREQ(result.inside.c_str(), PATH_LITERAL("foo/bar"));
result = LookupFile(Path::FromFS("config.h/foo/bar"));
result = LookupFile(Path::FromFS(PATH_LITERAL("config.h/foo/bar")));
EXPECT_TRUE(result);
EXPECT_STREQ(result.archive.c_str(), "config.h");
EXPECT_STREQ(result.inside.c_str(), "foo/bar");
EXPECT_STREQ(result.archive.c_str(), PATH_LITERAL("config.h"));
EXPECT_STREQ(result.inside.c_str(), PATH_LITERAL("foo/bar"));
}

View File

@@ -28,6 +28,7 @@
#include "pcm/AudioFormat.hxx"
#include "pcm/Convert.hxx"
#include "fs/Path.hxx"
#include "fs/NarrowPath.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StaticFifoBuffer.hxx"
#include "util/OptionDef.hxx"
@@ -47,7 +48,7 @@
struct CommandLine {
AudioFormat in_audio_format, out_audio_format;
Path config_path = nullptr;
FromNarrowPath config_path;
bool verbose = false;
};
@@ -71,7 +72,7 @@ ParseCommandLine(int argc, char **argv)
while (auto o = option_parser.Next()) {
switch (Option(o.index)) {
case OPTION_CONFIG:
c.config_path = Path::FromFS(o.value);
c.config_path = o.value;
break;
case OPTION_VERBOSE: