22 if (cachePath.empty())
27 cachePath.append(
"/pids/");
30 if (!std::filesystem::exists(dir) && !std::filesystem::create_directories(dir))
32 ARMARX_WARNING_S <<
"Unable to create Cache directory for the ScenarioManager plugin at "
37 std::string filename = cachePath + app->getPackageName() +
"." + app->getScenario()->getName() +
38 "." + app->getName() + (app->getInstanceName().empty() ?
"" :
".") +
39 app->getInstanceName() +
".pids";
41 if (!std::filesystem::exists(filename))
46 std::ifstream input(filename);
58 cachePath.append(
"/pids/");
61 if (!std::filesystem::exists(dir) && !std::filesystem::create_directories(dir))
63 ARMARX_WARNING_S <<
"Unable to create Cache directory for the ScenarioManager plugin at "
67 std::string filename = cachePath + app->getPackageName() +
"." + app->getScenario()->getName() +
68 "." + app->getName() + (app->getInstanceName().empty() ?
"" :
".") +
69 app->getInstanceName() +
".pids";
71 if (app->getPid() == -1)
73 std::filesystem::remove(std::filesystem::path(filename));
77 std::ofstream output(filename);
79 output << app->getPid();
87 cachePath.append(
"/pids/");
89 std::filesystem::remove_all(std::filesystem::path(cachePath));
void savePid(Data_Structure::ApplicationInstancePtr app)
int loadPid(Data_Structure::ApplicationInstancePtr app)
static std::string GetCachePath()
The base Cache directory of ArmarX.
#define ARMARX_WARNING_S
The logging level for unexpected behaviour, but not a serious problem.
std::shared_ptr< ApplicationInstance > ApplicationInstancePtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
fs::path remove_trailing_separator(fs::path p)