diff options
author | Loo Rong Jie <loorongjie@gmail.com> | 2018-08-07 04:12:29 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-08-07 04:13:52 -0700 |
commit | 6eefeb04b900be29d96a87dcdc3938151d98d9bf (patch) | |
tree | dfa9cb769b2dc0b5847de0f39948d7bb3b5cc0c4 /src/tools | |
parent | 68154e6525c9c18d25c4e82c34a847599da43e13 (diff) |
[singlejar] Set binary flag for Windows
/cc @laszlocsomor
Closes #5779.
PiperOrigin-RevId: 207693540
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/singlejar/output_jar.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/tools/singlejar/output_jar.cc b/src/tools/singlejar/output_jar.cc index 75be4ca1c7..5b6d24fc6b 100644 --- a/src/tools/singlejar/output_jar.cc +++ b/src/tools/singlejar/output_jar.cc @@ -259,8 +259,15 @@ bool OutputJar::Open() { if (file_) { diag_errx(1, "%s:%d: Cannot open output archive twice", __FILE__, __LINE__); } + // Set execute bits since we may produce an executable output file. - int fd = open(path(), O_CREAT|O_WRONLY|O_TRUNC, 0777); + int mode = O_CREAT | O_WRONLY | O_TRUNC; +#ifdef _WIN32 + // Make sure output file is in binary mode, or \r\n will be converted to \n. + mode |= _O_BINARY; +#endif + + int fd = open(path(), mode, 0777); if (fd < 0) { diag_warn("%s:%d: %s", __FILE__, __LINE__, path()); return false; |