1df13bdb6SMatt Spinler #include "extensions/openpower-pels/paths.hpp"
2df13bdb6SMatt Spinler 
3df13bdb6SMatt Spinler #include <filesystem>
4df13bdb6SMatt Spinler 
5df13bdb6SMatt Spinler namespace openpower
6df13bdb6SMatt Spinler {
7df13bdb6SMatt Spinler namespace pels
8df13bdb6SMatt Spinler {
9df13bdb6SMatt Spinler 
10df13bdb6SMatt Spinler // Use paths that work in unit tests.
11df13bdb6SMatt Spinler 
12df13bdb6SMatt Spinler std::filesystem::path getPELIDFile()
13df13bdb6SMatt Spinler {
14df13bdb6SMatt Spinler     static std::string idFile;
15df13bdb6SMatt Spinler 
16df13bdb6SMatt Spinler     if (idFile.empty())
17df13bdb6SMatt Spinler     {
18df13bdb6SMatt Spinler         char templ[] = "/tmp/logidtestXXXXXX";
19df13bdb6SMatt Spinler         std::filesystem::path dir = mkdtemp(templ);
20df13bdb6SMatt Spinler         idFile = dir / "logid";
21df13bdb6SMatt Spinler     }
22df13bdb6SMatt Spinler     return idFile;
23df13bdb6SMatt Spinler }
24df13bdb6SMatt Spinler 
2589fa082aSMatt Spinler std::filesystem::path getPELRepoPath()
2689fa082aSMatt Spinler {
2789fa082aSMatt Spinler     static std::string repoPath;
2889fa082aSMatt Spinler 
2989fa082aSMatt Spinler     if (repoPath.empty())
3089fa082aSMatt Spinler     {
3189fa082aSMatt Spinler         char templ[] = "/tmp/repopathtestXXXXXX";
3289fa082aSMatt Spinler         std::filesystem::path dir = mkdtemp(templ);
3389fa082aSMatt Spinler         repoPath = dir;
3489fa082aSMatt Spinler     }
3589fa082aSMatt Spinler     return repoPath;
3689fa082aSMatt Spinler }
3789fa082aSMatt Spinler 
38*367144cfSMatt Spinler std::filesystem::path getMessageRegistryPath()
39*367144cfSMatt Spinler {
40*367144cfSMatt Spinler     static std::string registryPath;
41*367144cfSMatt Spinler 
42*367144cfSMatt Spinler     if (registryPath.empty())
43*367144cfSMatt Spinler     {
44*367144cfSMatt Spinler         char templ[] = "/tmp/msgregtestXXXXXX";
45*367144cfSMatt Spinler         registryPath = mkdtemp(templ);
46*367144cfSMatt Spinler     }
47*367144cfSMatt Spinler 
48*367144cfSMatt Spinler     return registryPath;
49*367144cfSMatt Spinler }
50*367144cfSMatt Spinler 
51df13bdb6SMatt Spinler } // namespace pels
52df13bdb6SMatt Spinler } // namespace openpower
53