Skip to content

Commit

Permalink
Disable reading OSM files from network on Windows.
Browse files Browse the repository at this point in the history
Windows doesn't have pipes and fork, so the current implementation that calls
the curl binary doesn't work. This patch disables the code using #ifdefs. In
the future libcurl or something like it should be used internally, so we don't
need the fork any more.
  • Loading branch information
joto committed Aug 20, 2014
1 parent dd70565 commit d959a9e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/osmium/io/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ namespace osmium {

std::unique_ptr<osmium::io::detail::InputFormat> m_input;

#ifndef _WIN32
/**
* Fork and execute the given command in the child.
* A pipe is created between the child and the parent.
Expand Down Expand Up @@ -132,6 +133,7 @@ namespace osmium {
::close(pipefd[1]);
return pipefd[0];
}
#endif

/**
* Open File for reading. Handles URLs or normal files. URLs
Expand All @@ -144,7 +146,11 @@ namespace osmium {
static int open_input_file_or_url(const std::string& filename, int* childpid) {
std::string protocol = filename.substr(0, filename.find_first_of(':'));
if (protocol == "http" || protocol == "https" || protocol == "ftp" || protocol == "file") {
#ifndef _WIN32
return execute("curl", filename, childpid);
#else
throw std::runtime_error("Reading OSM files from the network currently not supported on Windows.");
#endif
} else {
return osmium::io::detail::open_for_reading(filename);
}
Expand Down Expand Up @@ -201,6 +207,7 @@ namespace osmium {

m_input->close();

#ifndef _WIN32
if (m_childpid) {
int status;
pid_t pid = ::waitpid(m_childpid, &status, 0);
Expand All @@ -212,6 +219,7 @@ namespace osmium {
#pragma GCC diagnostic pop
m_childpid = 0;
}
#endif

m_read_task.close();
}
Expand Down

0 comments on commit d959a9e

Please sign in to comment.