From dc919e841af7a0c864e687f19068406287664f06 Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Mon, 4 Nov 2002 15:01:40 -0500 Subject: [PATCH] Make directory if it does not exist yet --- Source/cmWriteFileCommand.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index 93ecd2d37..ab7f95732 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -44,12 +44,15 @@ bool cmWriteFileCommand::InitialPass(std::vector const& argsIn) message += *i; } } + std::string dir = cmSystemTools::GetFilenamePath(fileName); + cmSystemTools::MakeDirectory(dir.c_str()); std::ofstream file(fileName.c_str(), overwrite?std::ios::out : std::ios::app); if ( !file ) { - cmSystemTools::Error("Internal CMake error when trying to open file: ", - fileName.c_str()); + std::string error = "Internal CMake error when trying to open file: "; + error += fileName.c_str(); + this->SetError(error.c_str()); return false; } file << message << std::endl;