file: Report system error on failure to open file
This commit is contained in:
parent
2d5e3d2d2b
commit
2c448dbfe7
|
@ -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);
|
cmsys::ofstream file(fileName.c_str(), append?std::ios::app: std::ios::out);
|
||||||
if ( !file )
|
if ( !file )
|
||||||
{
|
{
|
||||||
std::string error = "Internal CMake error when trying to open file: ";
|
std::string error = "failed to open for writing (";
|
||||||
error += fileName.c_str();
|
error += cmSystemTools::GetLastSystemError();
|
||||||
error += " for writing.";
|
error += "):\n ";
|
||||||
|
error += fileName;
|
||||||
this->SetError(error);
|
this->SetError(error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -292,9 +293,10 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
|
||||||
|
|
||||||
if ( !file )
|
if ( !file )
|
||||||
{
|
{
|
||||||
std::string error = "Internal CMake error when trying to open file: ";
|
std::string error = "failed to open for reading (";
|
||||||
error += fileName.c_str();
|
error += cmSystemTools::GetLastSystemError();
|
||||||
error += " for reading.";
|
error += "):\n ";
|
||||||
|
error += fileName;
|
||||||
this->SetError(error);
|
this->SetError(error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ add_RunCMake_test(add_dependencies)
|
||||||
add_RunCMake_test(build_command)
|
add_RunCMake_test(build_command)
|
||||||
add_RunCMake_test(export)
|
add_RunCMake_test(export)
|
||||||
add_RunCMake_test(cmake_minimum_required)
|
add_RunCMake_test(cmake_minimum_required)
|
||||||
|
add_RunCMake_test(file)
|
||||||
add_RunCMake_test(find_package)
|
add_RunCMake_test(find_package)
|
||||||
add_RunCMake_test(get_filename_component)
|
add_RunCMake_test(get_filename_component)
|
||||||
add_RunCMake_test(if)
|
add_RunCMake_test(if)
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
project(${RunCMake_TEST} NONE)
|
||||||
|
include(${RunCMake_TEST}.cmake)
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,6 @@
|
||||||
|
CMake Error at FileOpenFailRead.cmake:[0-9]+ \(file\):
|
||||||
|
file failed to open for reading \(.*\):
|
||||||
|
|
||||||
|
.*/Tests/RunCMake/file/does_not_exist/file.txt
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1 @@
|
||||||
|
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist/file.txt" content)
|
|
@ -0,0 +1,3 @@
|
||||||
|
include(RunCMake)
|
||||||
|
|
||||||
|
run_cmake(FileOpenFailRead)
|
Loading…
Reference in New Issue