file: Report system error on failure to open file

This commit is contained in:
Brad King
2014-05-20 10:42:13 -04:00
parent 2d5e3d2d2b
commit 2c448dbfe7
7 changed files with 23 additions and 6 deletions
+8 -6
View File
@@ -232,9 +232,10 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
cmsys::ofstream file(fileName.c_str(), append?std::ios::app: std::ios::out);
if ( !file )
{
std::string error = "Internal CMake error when trying to open file: ";
error += fileName.c_str();
error += " for writing.";
std::string error = "failed to open for writing (";
error += cmSystemTools::GetLastSystemError();
error += "):\n ";
error += fileName;
this->SetError(error);
return false;
}
@@ -292,9 +293,10 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
if ( !file )
{
std::string error = "Internal CMake error when trying to open file: ";
error += fileName.c_str();
error += " for reading.";
std::string error = "failed to open for reading (";
error += cmSystemTools::GetLastSystemError();
error += "):\n ";
error += fileName;
this->SetError(error);
return false;
}