From d9ff992817f29d18cd503ece314a9367b3871365 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Thu, 29 Dec 2016 21:00:49 -0500 Subject: [PATCH] Fix temporary cti filename for MinGW --- src/base/ct2ctml.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/base/ct2ctml.cpp b/src/base/ct2ctml.cpp index 36f4d813c..f04e58fdb 100644 --- a/src/base/ct2ctml.cpp +++ b/src/base/ct2ctml.cpp @@ -85,6 +85,12 @@ static std::string call_ctml_writer(const std::string& text, bool isfile) bool temp_file_created = false; std::string temp_cti_file_name = std::tmpnam(nullptr); + if (temp_cti_file_name.find('\\') == 0) { + // Some versions of MinGW give paths in the root directory. Using the + // current directory is more likely to succeed. + temp_cti_file_name = "." + temp_cti_file_name; + } + if (isfile) { file = text; arg = "r'" + text + "'"; @@ -127,7 +133,7 @@ static std::string call_ctml_writer(const std::string& text, bool isfile) } else { // If we are here, then a temp file could not be created throw CanteraError("call_ctml_writer", "Very long source argument. " - "Error creating temporary file"); + "Error creating temporary file '{}'", temp_cti_file_name); } }