aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/protobuf/3.2.0/src/google/protobuf/testing/file.cc
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/protobuf/3.2.0/src/google/protobuf/testing/file.cc')
-rw-r--r--third_party/protobuf/3.2.0/src/google/protobuf/testing/file.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/third_party/protobuf/3.2.0/src/google/protobuf/testing/file.cc b/third_party/protobuf/3.2.0/src/google/protobuf/testing/file.cc
index 470512edff..b935488989 100644
--- a/third_party/protobuf/3.2.0/src/google/protobuf/testing/file.cc
+++ b/third_party/protobuf/3.2.0/src/google/protobuf/testing/file.cc
@@ -38,24 +38,28 @@
#ifdef _MSC_VER
#define WIN32_LEAN_AND_MEAN // yeah, right
#include <windows.h> // Find*File(). :(
-#include <io.h>
-#include <direct.h>
+// #include <direct.h>
#else
#include <dirent.h>
#include <unistd.h>
#endif
#include <errno.h>
+#include <google/protobuf/stubs/io_win32.h>
+
namespace google {
namespace protobuf {
#ifdef _WIN32
-#define mkdir(name, mode) mkdir(name)
// Windows doesn't have symbolic links.
#define lstat stat
-#ifndef F_OK
-#define F_OK 00 // not defined by MSVC for whatever reason
-#endif
+// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
+// them like we do below.
+using google::protobuf::stubs::access;
+using google::protobuf::stubs::chdir;
+using google::protobuf::stubs::fopen;
+using google::protobuf::stubs::mkdir;
+using google::protobuf::stubs::stat;
#endif
bool File::Exists(const string& name) {
@@ -113,6 +117,9 @@ void File::WriteStringToFileOrDie(const string& contents, const string& name) {
}
bool File::CreateDir(const string& name, int mode) {
+ if (!name.empty()) {
+ GOOGLE_CHECK_OK(name.back() != '.');
+ }
return mkdir(name.c_str(), mode) == 0;
}