mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-08 23:00:07 -06:00
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.
This commit is contained in:
committed by
Brad King
parent
743f24bac6
commit
2db4945150
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user