Browse Source

correct the way of testing file mode on Windows

June 5 years ago
parent
commit
727e6e4e60
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/google/protobuf/compiler/importer.cc

+ 4 - 0
src/google/protobuf/compiler/importer.cc

@@ -495,7 +495,11 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile(
   do {
   do {
     ret = stat(filename.c_str(), &sb);
     ret = stat(filename.c_str(), &sb);
   } while (ret != 0 && errno == EINTR);
   } while (ret != 0 && errno == EINTR);
+#ifdef _WIN32
+  if ((sb.st_mode & _S_IFMT) == _S_IFREG) {
+#else
   if (!S_ISREG(sb.st_mode)) {
   if (!S_ISREG(sb.st_mode)) {
+#endif
     last_error_message_ = "Input file is not a regular file.";
     last_error_message_ = "Input file is not a regular file.";
     return NULL;
     return NULL;
   }
   }