Commit 2db49451 authored by Ruslan Baratov's avatar Ruslan Baratov Committed by Brad King
Browse files

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.
parent 743f24ba
......@@ -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;
return false;
if (mode) {
cmSystemTools::SetPermissions(fileName.c_str(), mode);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment