Skip to content

Commit

Permalink
Update for base branch
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <michael@openrobotics.org>
  • Loading branch information
mjcarroll committed Sep 14, 2021
1 parent 78e05e6 commit 9957c49
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/TempDirectory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ std::string createTempDirectory(
fs::path templatePath = _baseName + "XXXXXX";

std::string fullTemplateStr = (parentPath / templatePath).string();
if (!createDirectories(parentPath.string()))
if (!createDirectories(parentPath.string()))
{
std::error_code ec{errno, std::system_category()};
errno = 0;
Expand All @@ -87,22 +87,23 @@ std::string createTempDirectory(

#ifdef _WIN32
errno_t errcode = _mktemp_s(&fullTemplateStr[0], fullTemplateStr.size() + 1);
if (errcode)
if (errcode)
{
std::error_code ec(static_cast<int>(errcode), std::system_category());
throw std::system_error(ec,
"could not format the temp directory name template");
}
const fs::path finalPath{fullTemplateStr};
if (!createDirectories(finalPath.string()))
if (!createDirectories(finalPath.string()))
{
std::error_code ec(static_cast<int>(GetLastError()),
std::system_category());
throw std::system_error(ec, "could not create the temp directory");
}
#else
const char * dirName = mkdtemp(&fullTemplateStr[0]);
if (dirName == nullptr) {
if (dirName == nullptr)
{
std::error_code ec{errno, std::system_category()};
errno = 0;
throw std::system_error(ec,
Expand All @@ -121,7 +122,7 @@ std::string ignition::common::createTempDirectory(
const FilesystemWarningOp _warningOp)
{
std::string ret;
try
try
{
ret = ::createTempDirectory(_baseName, _parentPath);
}
Expand Down

0 comments on commit 9957c49

Please sign in to comment.