diff options
Diffstat (limited to 'src/google/protobuf/testing/file.cc')
-rw-r--r-- | src/google/protobuf/testing/file.cc | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/google/protobuf/testing/file.cc b/src/google/protobuf/testing/file.cc index 470512ed..26cb0a67 100644 --- a/src/google/protobuf/testing/file.cc +++ b/src/google/protobuf/testing/file.cc @@ -38,24 +38,31 @@ #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 +// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import +// them like we do below. #endif + +#ifdef _WIN32 +using google::protobuf::internal::win32::access; +using google::protobuf::internal::win32::chdir; +using google::protobuf::internal::win32::fopen; +using google::protobuf::internal::win32::mkdir; +using google::protobuf::internal::win32::stat; #endif bool File::Exists(const string& name) { @@ -113,6 +120,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[name.size() - 1] != '.'); + } return mkdir(name.c_str(), mode) == 0; } |