Skip to content

Commit

Permalink
replace access() by _access() on Windows, re #49
Browse files Browse the repository at this point in the history
  • Loading branch information
gentryx committed Mar 3, 2017
1 parent 74f2fb3 commit a54034d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/libgeodecomp/misc/tempfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#pragma warning( pop )
#endif

#ifndef _WIN32
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif

Expand All @@ -44,7 +46,12 @@ std::string TempFile::serial(const std::string& prefix)
std::string filename = prefix + StringOps::itoa(r);
buf << filename;
name += buf.str();
if (access(name.c_str(), F_OK) == -1) {
#ifdef _WIN32
int access_result = _access(name.c_str(), 0);
#else
int access_result = access(name.c_str(), F_OK);
#endif
if (access_result != 0) {
return name;
}
}
Expand Down

0 comments on commit a54034d

Please sign in to comment.