Skip to content

Commit

Permalink
Respect $TMPDIR in chip-tool config (#22738)
Browse files Browse the repository at this point in the history
Some systems may have a different temporary directory. Respect this in
chip-tool.
  • Loading branch information
mspang authored and pull[bot] committed Dec 6, 2023
1 parent f67085b commit 1af9fe8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions examples/chip-tool/config/PersistentStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,19 @@ constexpr LogCategory kDefaultLoggingLevel = kLogCategory_Automation;

std::string GetFilename(const char * name)
{
const char * tmpdir = getenv("TMPDIR");

if (tmpdir == nullptr)
{
tmpdir = "/tmp";
}

if (name == nullptr)
{
return "/tmp/chip_tool_config.ini";
return std::string(tmpdir) + "/chip_tool_config.ini";
}
return "/tmp/chip_tool_config." + std::string(name) + ".ini";

return std::string(tmpdir) + "/chip_tool_config." + std::string(name) + ".ini";
}

CHIP_ERROR PersistentStorage::Init(const char * name)
Expand Down

0 comments on commit 1af9fe8

Please sign in to comment.