/** * Helper.hh * * Created on: Dec 13, 2012 * Author: AKKA IS */ #ifndef HELPER_HH_ #define HELPER_HH_ #include #include #include namespace AMDA { namespace Helpers { /** * @brief Tools box for AMDA */ class Helper { public: /** * @brief get files in rootDir with pattern * @return the number of match file * @param rootDir path of entries search * @param files return's list of match files * @param pattern regexec pattern */ static int getMatchFiles(const char* rootDir, std::vector &files, const char* pattern); /** * @brief return true if subject match format */ static bool format(const char* subject, const char* format) ; /** * @brief create a directory * @detail if path exist, nothing is made * @return: 0 if path exist or is create * errno if path exist and is not a directory or if an error occurred (return errno = EEXIST path already exists and is not a directory * @param path: path directory to create */ static int mkdir(const char* path) ; /** * @brief return date of file * @return date of file or 0 if a problem occurred */ static time_t dateOfFile(const char* path) ; /** * @brief execute in posix system the command and write in pLogger errors. * @details the command must not have a output redirection. * an error is detected if command return a value different of 0. * @return true if an error occurred */ static bool SystemCommand(std::string command, log4cxx::LoggerPtr pLogger); /** * @brief return the pid of process */ static const std::string &getPID() ; /** * @brief pid of process in string format */ static std::string _pid; }; } /* namespace Helpers */ } /* namespace AMDA */ #endif /* HELPER_HH_ */