6 #include <SimoxUtility/algorithm/string.h>
21 std::string
ret = segmentName;
25 ret = simox::alg::replace_all(
ret,
s, r);
33 std::string
ret = escapedName;
38 ret = simox::alg::replace_all(
ret, r,
s);
58 for (
char const& ch :
s)
60 if (std::isdigit(ch) == 0)
72 if (
split.size() != 3)
86 std::filesystem::path p = base;
87 if (
id.hasMemoryName())
91 if (
id.hasCoreSegmentName())
95 if (
id.hasProviderSegmentName())
99 if (
id.hasEntityName())
103 if (
id.hasTimestamp())
107 p /=
id.timestampStr();
109 if (
id.hasInstanceIndex())
111 p /=
id.instanceIndexStr();
120 return std::filesystem::exists(p) and std::filesystem::is_directory(p);
126 return std::filesystem::exists(p) && std::filesystem::is_regular_file(p);
134 if (createIfNotExistent)
136 std::filesystem::create_directories(p);
140 throw armarx::LocalException(
"Directory existence cannot be ensured: " +
152 if (createIfNotExistent)
154 std::string content =
"";
160 throw armarx::LocalException(
"Could not find file: " + p.string());
168 std::ofstream dataofs;
172 throw armarx::LocalException(
"Could not write data to filesystem file '" + p.string() +
173 "'. Skipping this file.");
175 dataofs.write(
reinterpret_cast<const char*
>(
data.data()),
data.size());
179 std::vector<unsigned char>
182 std::ifstream dataifs(p);
183 std::vector<unsigned char> datafilecontent((std::istreambuf_iterator<char>(dataifs)),
184 (std::istreambuf_iterator<char>()));
186 return datafilecontent;
189 std::vector<std::filesystem::path>
192 std::vector<std::filesystem::path>
ret;
193 for (
const auto& subdir : std::filesystem::directory_iterator(p))
195 std::filesystem::path subdirPath = subdir.path();
196 if (std::filesystem::is_directory(subdirPath))
198 ret.push_back(subdirPath);
201 std::sort(
ret.begin(),
203 [](
const std::filesystem::path&
a,
const std::filesystem::path& b) ->
bool
204 { return a.string() > b.string(); });
208 std::vector<std::filesystem::path>
211 std::vector<std::filesystem::path>
ret;
212 for (
const auto& subdir : std::filesystem::directory_iterator(p))
214 std::filesystem::path subdirPath = subdir.path();
215 if (std::filesystem::is_regular_file(subdirPath))
217 ret.push_back(subdirPath);
220 std::sort(
ret.begin(),
222 [](
const std::filesystem::path&
a,
const std::filesystem::path& b) ->
bool
223 { return a.string() > b.string(); });