diff options
author | Ruslan Baratov <ruslan_baratov@yahoo.com> | 2018-05-15 18:36:36 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-05-16 14:34:28 (GMT) |
commit | 2db4945150a1a94aeaab6add1b5b371ba6fbdc59 (patch) | |
tree | 9bad7136f33983d46117a560d9a165b773e35958 | |
parent | 743f24bac68010c0157dc0349958e09ed1784f5f (diff) | |
download | CMake-2db4945150a1a94aeaab6add1b5b371ba6fbdc59.zip CMake-2db4945150a1a94aeaab6add1b5b371ba6fbdc59.tar.gz CMake-2db4945150a1a94aeaab6add1b5b371ba6fbdc59.tar.bz2 |
file(WRITE): Report errors during write operation
We already report an error if the file cannot be opened for writing.
Add another check to report an error if a write operation itself fails.
-rw-r--r-- | Source/cmFileCommand.cxx | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 6c1a869..1e47687 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -232,6 +232,14 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args, } std::string message = cmJoin(cmMakeRange(i, args.end()), std::string()); file << message; + if (!file) { + std::string error = "write failed ("; + error += cmSystemTools::GetLastSystemError(); + error += "):\n "; + error += fileName; + this->SetError(error); + return false; + } file.close(); if (mode) { cmSystemTools::SetPermissions(fileName.c_str(), mode); |