Skip to content

Commit

Permalink
Use greyhound:// to signify the greyhound reader, inferring http:// p…
Browse files Browse the repository at this point in the history
…aths from their actual file extension.
  • Loading branch information
connormanning committed Jul 23, 2016
1 parent 6f4fbd3 commit dcca745
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/StageFactory.cpp
Expand Up @@ -138,7 +138,6 @@ std::string StageFactory::inferReaderDriver(const std::string& filename)
{ "bpf", "readers.bpf" },
{ "csd", "readers.optech" },
{ "greyhound", "readers.greyhound" },
{ "http", "readers.greyhound" },
{ "icebridge", "readers.icebridge" },
{ "las", "readers.las" },
{ "laz", "readers.las" },
Expand All @@ -157,10 +156,12 @@ std::string StageFactory::inferReaderDriver(const std::string& filename)
{ "h5", "readers.icebridge" }
};

static const std::string ghPrefix("greyhound://");

std::string ext;
// filename may actually be a greyhound uri + pipelineId
if (Utils::iequals(filename.substr(0, 4), "http"))
ext = ".http"; // Make it look like an extension.
if (Utils::iequals(filename.substr(0, ghPrefix.size()), ghPrefix))
ext = ".greyhound"; // Make it look like an extension.
else
ext = FileUtils::extension(filename);

Expand Down
5 changes: 3 additions & 2 deletions test/unit/StageFactoryTest.cpp
Expand Up @@ -83,7 +83,7 @@ TEST(StageFactoryTest, Load4)
ASSERT_FALSE(Utils::contains(ns, "readers.las"));
ASSERT_TRUE(Utils::contains(ns, "writers.bpf"));
}

TEST(StageFactoryTest, extensionTest)
{
EXPECT_EQ(StageFactory::inferWriterDriver("foo.laz"), "writers.las");
Expand All @@ -93,7 +93,8 @@ TEST(StageFactoryTest, extensionTest)

EXPECT_EQ(StageFactory::inferReaderDriver("foo.laz"), "readers.las");
EXPECT_EQ(StageFactory::inferReaderDriver("foo.las"), "readers.las");
EXPECT_EQ(StageFactory::inferReaderDriver("http://foo.bar.baz"),
EXPECT_EQ(StageFactory::inferReaderDriver("http://foo.laz"), "readers.las");
EXPECT_EQ(StageFactory::inferReaderDriver("greyhound://foo.bar.baz"),
"readers.greyhound");

StringList ext = { "las", "laz" };
Expand Down

0 comments on commit dcca745

Please sign in to comment.