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