Skip to content

Commit

Permalink
Fix detecting file as directory on zOS issue #8051
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdi-hm authored and acozzette committed Nov 17, 2020
1 parent a73c8e0 commit 51bdb51
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/google/protobuf/compiler/importer.cc
Expand Up @@ -495,10 +495,17 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile(
do {
ret = stat(filename.c_str(), &sb);
} while (ret != 0 && errno == EINTR);
#if defined(_WIN32)
if (ret == 0 && sb.st_mode & S_IFDIR) {
last_error_message_ = "Input file is a directory.";
return NULL;
}
#elif
if (ret == 0 && S_ISDIR(sb.st_mode)) {
last_error_message_ = "Input file is a directory.";
return NULL;
}
#endif
int file_descriptor;
do {
file_descriptor = open(filename.c_str(), O_RDONLY);
Expand Down

0 comments on commit 51bdb51

Please sign in to comment.