1*97f7abcfSMatt Spinler /**
2*97f7abcfSMatt Spinler  * Copyright © 2019 IBM Corporation
3*97f7abcfSMatt Spinler  *
4*97f7abcfSMatt Spinler  * Licensed under the Apache License, Version 2.0 (the "License");
5*97f7abcfSMatt Spinler  * you may not use this file except in compliance with the License.
6*97f7abcfSMatt Spinler  * You may obtain a copy of the License at
7*97f7abcfSMatt Spinler  *
8*97f7abcfSMatt Spinler  *     http://www.apache.org/licenses/LICENSE-2.0
9*97f7abcfSMatt Spinler  *
10*97f7abcfSMatt Spinler  * Unless required by applicable law or agreed to in writing, software
11*97f7abcfSMatt Spinler  * distributed under the License is distributed on an "AS IS" BASIS,
12*97f7abcfSMatt Spinler  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*97f7abcfSMatt Spinler  * See the License for the specific language governing permissions and
14*97f7abcfSMatt Spinler  * limitations under the License.
15*97f7abcfSMatt Spinler  */
16df13bdb6SMatt Spinler #include "extensions/openpower-pels/paths.hpp"
17df13bdb6SMatt Spinler 
18df13bdb6SMatt Spinler #include <filesystem>
19df13bdb6SMatt Spinler 
20df13bdb6SMatt Spinler namespace openpower
21df13bdb6SMatt Spinler {
22df13bdb6SMatt Spinler namespace pels
23df13bdb6SMatt Spinler {
24df13bdb6SMatt Spinler 
25df13bdb6SMatt Spinler // Use paths that work in unit tests.
26df13bdb6SMatt Spinler 
27df13bdb6SMatt Spinler std::filesystem::path getPELIDFile()
28df13bdb6SMatt Spinler {
29df13bdb6SMatt Spinler     static std::string idFile;
30df13bdb6SMatt Spinler 
31df13bdb6SMatt Spinler     if (idFile.empty())
32df13bdb6SMatt Spinler     {
33df13bdb6SMatt Spinler         char templ[] = "/tmp/logidtestXXXXXX";
34df13bdb6SMatt Spinler         std::filesystem::path dir = mkdtemp(templ);
35df13bdb6SMatt Spinler         idFile = dir / "logid";
36df13bdb6SMatt Spinler     }
37df13bdb6SMatt Spinler     return idFile;
38df13bdb6SMatt Spinler }
39df13bdb6SMatt Spinler 
4089fa082aSMatt Spinler std::filesystem::path getPELRepoPath()
4189fa082aSMatt Spinler {
4289fa082aSMatt Spinler     static std::string repoPath;
4389fa082aSMatt Spinler 
4489fa082aSMatt Spinler     if (repoPath.empty())
4589fa082aSMatt Spinler     {
4689fa082aSMatt Spinler         char templ[] = "/tmp/repopathtestXXXXXX";
4789fa082aSMatt Spinler         std::filesystem::path dir = mkdtemp(templ);
4889fa082aSMatt Spinler         repoPath = dir;
4989fa082aSMatt Spinler     }
5089fa082aSMatt Spinler     return repoPath;
5189fa082aSMatt Spinler }
5289fa082aSMatt Spinler 
53367144cfSMatt Spinler std::filesystem::path getMessageRegistryPath()
54367144cfSMatt Spinler {
55367144cfSMatt Spinler     static std::string registryPath;
56367144cfSMatt Spinler 
57367144cfSMatt Spinler     if (registryPath.empty())
58367144cfSMatt Spinler     {
59367144cfSMatt Spinler         char templ[] = "/tmp/msgregtestXXXXXX";
60367144cfSMatt Spinler         registryPath = mkdtemp(templ);
61367144cfSMatt Spinler     }
62367144cfSMatt Spinler 
63367144cfSMatt Spinler     return registryPath;
64367144cfSMatt Spinler }
65367144cfSMatt Spinler 
66df13bdb6SMatt Spinler } // namespace pels
67df13bdb6SMatt Spinler } // namespace openpower
68