Skip to content

Commit

Permalink
Only use arbiter if we're accessing a remote file.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Mar 19, 2020
1 parent c4cc229 commit 7dc5df4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
29 changes: 18 additions & 11 deletions pdal/PDALUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ std::ostream *createFile(const std::string& path, bool asBinary)
{
ostream *ofs(nullptr);

arbiter::Arbiter a;
const bool remote(a.hasDriver(path) && a.isRemote(path));

if (remote)
if (isRemote(path))
{
arbiter::Arbiter a;
if (!a.hasDriver(path))
return ofs;
try
{
ofs = new ArbiterOutStream(tempFilename(path), path,
Expand Down Expand Up @@ -282,10 +282,15 @@ std::ostream *createFile(const std::string& path, bool asBinary)

bool isRemote(const std::string& path)
{
arbiter::Arbiter a;
return a.isRemote(path);
const StringList prefixes { "gs://", "dropbox://", "http://", "https://" };

for (const string& prefix : prefixes)
if (Utils::startsWith(path, prefix))
return true;
return false;
}


std::string fetchRemote(const std::string& path)
{
std::string temp = tempFilename(path);
Expand All @@ -296,9 +301,11 @@ std::string fetchRemote(const std::string& path)

std::istream *openFile(const std::string& path, bool asBinary)
{
arbiter::Arbiter a;
if (a.hasDriver(path) && a.isRemote(path))
if (isRemote(path))
{
arbiter::Arbiter a;
if (!a.hasDriver(path))
return nullptr;
try
{
return new ArbiterInStream(tempFilename(path), path,
Expand Down Expand Up @@ -342,10 +349,10 @@ void closeFile(std::istream *in)
*/
bool fileExists(const std::string& path)
{
arbiter::Arbiter a;
if (a.hasDriver(path) && a.isRemote(path) && a.exists(path))
if (isRemote(path))
{
return true;
arbiter::Arbiter a;
return (a.hasDriver(path) && a.exists(path));
}

// Arbiter doesn't handle our STDIN hacks.
Expand Down
2 changes: 1 addition & 1 deletion plugins/e57/libE57Format/src/ImageFileImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ namespace e57
}

/// Check if file length matches actual physical length
if (header.filePhysicalLength != file->length(CheckedFile::Physical))
if ((off_t)header.filePhysicalLength != file->length(CheckedFile::Physical))
{
throw E57_EXCEPTION2(E57_ERROR_BAD_FILE_LENGTH,
"fileName=" + file->fileName()
Expand Down

0 comments on commit 7dc5df4

Please sign in to comment.