8 std::vector<std::string>
11 std::vector<std::string> containers;
19 if (!
id.hasEntityName() ||
id.hasTimestamp())
21 std::vector<std::filesystem::path> dirs = getAllDirectories(
id);
24 for (
auto& path : dirs)
26 std::string container = path.filename().string();
28 if (!container.empty())
30 containers.emplace_back(container);
37 std::vector<std::filesystem::path> dayDirs = getAllDirectories(
id);
39 for (std::filesystem::path& dayDir : dayDirs)
43 ARMARX_WARNING <<
"Found a non-date folder inside an entity '" <<
id.str()
44 <<
"' with name '" << dayDir.filename() <<
"'. "
45 <<
"Ignoring this folder, however this is a bad situation.";
51 for (std::filesystem::path& secondDir : secondDirs)
55 ARMARX_WARNING <<
"Found a non-timestamp folder inside an entity '"
56 <<
id.str() <<
"' hours folder with name '"
57 << secondDir.filename() <<
"'. "
58 <<
"Ignoring this folder, however this is a bad situation.";
62 std::vector<std::filesystem::path> timestampDirs =
65 for (std::filesystem::path& timestampDir : timestampDirs)
70 <<
"Found a non-timestamp folder inside an entity '" <<
id.str()
71 <<
"' seconds folder with name '" << timestampDir.filename()
73 <<
"Ignoring this folder, however this is a bad situation.";
77 std::string container = timestampDir.filename().string();
79 if (!container.empty())
81 containers.emplace_back(container);
91 std::vector<std::string>
96 return std::vector<std::string>();
99 std::vector<std::filesystem::path>
files = getAllFiles(
id);
100 std::vector<std::string> filesStr;
102 for (
auto& path :
files)
104 std::string item = path.filename().string();
108 filesStr.emplace_back(item);
124 auto path_to_id = getFullPath(
id);
125 auto correct_container_path = path_to_id / key;
128 return contains_container;
139 return fileExists(
id, key);
145 std::vector<unsigned char>&
data)
152 ensureFullPathExists(
id,
true);
153 ensureFileExists(
id, key,
true);
155 if (enoughDiskSpaceLeft())
157 writeDataToFile(
id, key,
data);
161 ARMARX_DEBUG <<
"Not enough DiskSpace available for DiskPersistance-Strategy";
165 std::vector<unsigned char>
170 return std::vector<unsigned char>();
173 if (fileExists(
id, key))
175 return readDataFromFile(
id, key);
178 return std::vector<unsigned char>();
181 std::filesystem::path
182 DiskPersistence::getMemoryParentPath()
184 std::string p = memoryParentPath_.string();
191 std::filesystem::path
207 auto p = getFullPath(
id);
214 auto p = getFullPath(
id) /
filename;
220 bool createIfNotExistent)
222 auto p = getFullPath(
id);
229 bool createIfNotExistent)
231 auto p = getFullPath(
id) /
filename;
238 const std::vector<unsigned char>&
data)
240 auto p = getFullPath(
id) /
filename;
244 std::vector<unsigned char>
248 auto p = getFullPath(
id) /
filename;
252 std::vector<std::filesystem::path>
255 if (fullPathExists(
id))
257 auto p = getFullPath(
id);
261 return std::vector<std::filesystem::path>();
264 std::vector<std::filesystem::path>
267 if (fullPathExists(
id))
269 auto p = getFullPath(
id);
273 return std::vector<std::filesystem::path>();
277 DiskPersistence::enoughDiskSpaceLeft()
279 std::string path_to_disk = this->getMemoryParentPath();
280 bool debug_info_output_enabled =
false;
282 if (std::filesystem::exists(path_to_disk))
287 int const conversion_factor = 1024;
289 auto available_space = space_info.available /
290 (conversion_factor * conversion_factor * conversion_factor);
292 if (debug_info_output_enabled)
295 << space_info.capacity /
296 (conversion_factor * conversion_factor * conversion_factor)
300 (conversion_factor * conversion_factor * conversion_factor)
303 << space_info.available /
304 (conversion_factor * conversion_factor * conversion_factor)
309 return static_cast<bool>(available_space >= this->
minDiskSpace);
311 catch (
const std::filesystem::filesystem_error& e)
318 ARMARX_DEBUG <<
"Error while trying to get info on available disk space";
324 ARMARX_DEBUG <<
"Cannot find path to disk and thus cannot check if enough space is "