Skip to content

Commit

Permalink
Merge pull request #78 from ateucher/geojsonrw-fix
Browse files Browse the repository at this point in the history
Use _pipe from io.h on Windows
  • Loading branch information
sckott committed Feb 18, 2016
2 parents bdd0c9e + 5ff4b26 commit 2f6beff
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/captured_write_ogr.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include <Rcpp.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif

using namespace Rcpp;

Expand Down Expand Up @@ -50,8 +54,11 @@ CharacterVector capturedWriteOGR(SEXP obj,

// ok, there's some error checking if we couldn't even
// get the hack started

if (pipe(out_pipe) != 0 ) { return(NA_STRING); }
#ifdef _WIN32
if (_pipe(out_pipe, MAX_LEN, 0) != 0 ) { return(NA_STRING); }
#else
if (pipe(out_pipe) != 0 ) { return(NA_STRING); }
#endif

dup2(out_pipe[1], STDOUT_FILENO);
close(out_pipe[1]);
Expand Down

0 comments on commit 2f6beff

Please sign in to comment.