util.h
Go to the documentation of this file.
1#pragma once
2
3#include "../../../../../core/error.h"
4#include "filesystem_util.h"
5#include "minizip_util.h"
6
8{
9 namespace constantes
10 {
11 const std::string TYPE_FILENAME = "type.aron";
12 const std::string DATA_FILENAME = "data.aron";
13 const std::string METADATA_FILENAME = "metadata.aron";
14 } // namespace constantes
15
16 namespace util
17 {
18 // check whether a string is a number (e.g. timestamp folders)
19 bool isNumber(const std::string& s);
20
21 bool checkIfBasePathExists(const std::filesystem::path& mPath);
22
23 void ensureBasePathExists(const std::filesystem::path& mPath,
24 bool createIfNotExistent = true);
25
26 bool checkIfFolderExists(const std::filesystem::path& mPath,
27 const std::filesystem::path& p);
28
29 void ensureFolderExists(const std::filesystem::path& mPath,
30 const std::filesystem::path& p,
31 bool createIfNotExistent = true);
32
33 bool checkIfFileExists(const std::filesystem::path& mPath, const std::filesystem::path& p);
34
35 void ensureFileExists(const std::filesystem::path& mPath, const std::filesystem::path& p);
36
37 void writeDataToFile(const std::filesystem::path& mPath,
38 const std::filesystem::path& p,
39 const std::vector<unsigned char>& data);
40
41 void writeDataToFileRepeated(const std::filesystem::path& mPath,
42 const std::filesystem::path& p,
43 const std::vector<unsigned char>& data,
44 const unsigned int maxTries = 100,
45 const unsigned int sleepTimeMs = 10);
46
47 std::vector<unsigned char> readDataFromFile(const std::filesystem::path& mPath,
48 const std::filesystem::path& p);
49
50 std::vector<std::string> getAllDirectories(const std::filesystem::path& mPath,
51 const std::filesystem::path& p);
52
53 std::vector<std::string> getAllFiles(const std::filesystem::path& mPath,
54 const std::filesystem::path& p);
55 } // namespace util
56} // namespace armarx::armem::server::ltm::disk
bool checkIfFolderExists(const std::filesystem::path &mPath, const std::filesystem::path &p)
Definition util.cpp:47
bool checkIfBasePathExists(const std::filesystem::path &mPath)
Definition util.cpp:25
std::vector< std::string > getAllDirectories(const std::filesystem::path &mPath, const std::filesystem::path &p)
Definition util.cpp:145
void ensureBasePathExists(const std::filesystem::path &mPath, bool createIfNotExistent)
Definition util.cpp:35
std::vector< std::string > getAllFiles(const std::filesystem::path &mPath, const std::filesystem::path &p)
Definition util.cpp:156
bool checkIfFileExists(const std::filesystem::path &mPath, const std::filesystem::path &p)
Definition util.cpp:71
void ensureFolderExists(const std::filesystem::path &mPath, const std::filesystem::path &p, bool createIfNotExistent)
Definition util.cpp:58
std::vector< unsigned char > readDataFromFile(const std::filesystem::path &mPath, const std::filesystem::path &p)
Definition util.cpp:134
bool isNumber(const std::string &s)
Definition util.cpp:12
void writeDataToFile(const std::filesystem::path &mPath, const std::filesystem::path &p, const std::vector< unsigned char > &data)
Definition util.cpp:93
void ensureFileExists(const std::filesystem::path &mPath, const std::filesystem::path &p)
Definition util.cpp:82
void writeDataToFileRepeated(const std::filesystem::path &mPath, const std::filesystem::path &p, const std::vector< unsigned char > &data, const unsigned int maxTries, const unsigned int sleepTimeMs)
Definition util.cpp:106