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
armarx::armem::server::ltm::disk::util::writeDataToFileRepeated
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
armarx::armem::server::ltm::disk::util::ensureFolderExists
void ensureFolderExists(const std::filesystem::path &mPath, const std::filesystem::path &p, bool createIfNotExistent)
Definition: util.cpp:58
armarx::armem::server::ltm::disk::util::checkIfFolderExists
bool checkIfFolderExists(const std::filesystem::path &mPath, const std::filesystem::path &p)
Definition: util.cpp:47
armarx::armem::server::ltm::disk::constantes::DATA_FILENAME
const std::string DATA_FILENAME
Definition: util.h:12
armarx::armem::server::ltm::disk::util::ensureBasePathExists
void ensureBasePathExists(const std::filesystem::path &mPath, bool createIfNotExistent)
Definition: util.cpp:35
armarx::armem::server::ltm::disk::util::checkIfFileExists
bool checkIfFileExists(const std::filesystem::path &mPath, const std::filesystem::path &p)
Definition: util.cpp:71
filesystem_util.h
armarx::armem::server::ltm::disk::util::writeDataToFile
void writeDataToFile(const std::filesystem::path &mPath, const std::filesystem::path &p, const std::vector< unsigned char > &data)
Definition: util.cpp:93
armarx::armem::server::ltm::disk::util::getAllDirectories
std::vector< std::string > getAllDirectories(const std::filesystem::path &mPath, const std::filesystem::path &p)
Definition: util.cpp:145
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::armem::server::ltm::disk::util::getAllFiles
std::vector< std::string > getAllFiles(const std::filesystem::path &mPath, const std::filesystem::path &p)
Definition: util.cpp:156
minizip_util.h
armarx::armem::server::ltm::disk::util::isNumber
bool isNumber(const std::string &s)
Definition: util.cpp:12
armarx::armem::server::ltm::disk::constantes::METADATA_FILENAME
const std::string METADATA_FILENAME
Definition: util.h:13
armarx::armem::server::ltm::disk::util::readDataFromFile
std::vector< unsigned char > readDataFromFile(const std::filesystem::path &mPath, const std::filesystem::path &p)
Definition: util.cpp:134
armarx::armem::server::ltm::disk::util::ensureFileExists
void ensureFileExists(const std::filesystem::path &mPath, const std::filesystem::path &p)
Definition: util.cpp:82
armarx::armem::server::ltm::disk
Definition: filesystem_util.cpp:7
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::armem::server::ltm::disk::constantes::TYPE_FILENAME
const std::string TYPE_FILENAME
Definition: util.h:11
armarx::armem::server::ltm::disk::util::checkIfBasePathExists
bool checkIfBasePathExists(const std::filesystem::path &mPath)
Definition: util.cpp:25