diff options
author | Brad King <brad.king@kitware.com> | 2018-05-17 13:05:57 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-05-17 13:06:22 (GMT) |
commit | 4ba7db4ff36a20512b0bd9e725b7dea5246e7554 (patch) | |
tree | 6cb641d920ade288053888dfbc35cd772f2ccd4b /Source | |
parent | 6411180969ee1a384d9f37f76fa71a3690113f1d (diff) | |
parent | 2db4945150a1a94aeaab6add1b5b371ba6fbdc59 (diff) | |
download | CMake-4ba7db4ff36a20512b0bd9e725b7dea5246e7554.zip CMake-4ba7db4ff36a20512b0bd9e725b7dea5246e7554.tar.gz CMake-4ba7db4ff36a20512b0bd9e725b7dea5246e7554.tar.bz2 |
Merge topic 'pr.file_write_check'
2db4945150 file(WRITE): Report errors during write operation
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2076
Diffstat (limited to 'Source')
-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); |