aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/command_line_interface.cc
diff options
context:
space:
mode:
authorGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2009-12-19 04:50:00 +0000
committerGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2009-12-19 04:50:00 +0000
commit684d45b2feac114a0152cf4458846fbeca61b5d9 (patch)
tree781a604308f2866d6b321d6cfbe238c2732cc469 /src/google/protobuf/compiler/command_line_interface.cc
parentbdbb863099c7ef3e1ecdeefa732798e095b85fb8 (diff)
Fix build on MinGW/Win32 (including implementing Subprocess using CreateProcess()).
Diffstat (limited to 'src/google/protobuf/compiler/command_line_interface.cc')
-rw-r--r--src/google/protobuf/compiler/command_line_interface.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index 39bd370e..a611fcee 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -529,10 +529,19 @@ CommandLineInterface::InsertionOutputStream::~InsertionOutputStream() {
// If everything was successful, overwrite the original file with the temp
// file.
if (!had_error) {
+#ifdef _WIN32
+ // rename() on Windows fails if the file exists.
+ if (!MoveFileEx(temp_filename_.c_str(), filename_.c_str(),
+ MOVEFILE_REPLACE_EXISTING)) {
+ cerr << filename_ << ": MoveFileEx: "
+ << Subprocess::Win32ErrorMessage(GetLastError()) << endl;
+ }
+#else // _WIN32
if (rename(temp_filename_.c_str(), filename_.c_str()) < 0) {
cerr << filename_ << ": rename: " << strerror(errno) << endl;
had_error = true;
}
+#endif // !_WIN32
}
if (had_error) {