Blame view

src/helpers/Helper.hh 1.9 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
 * Helper.hh
 *
 *  Created on: Dec 13, 2012
 *      Author: AKKA IS
 */

#ifndef HELPER_HH_
#define HELPER_HH_

#include <string>
#include <vector>
#include <log4cxx/logger.h>

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<std::string> &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);


c1f4db8e   Benjamin Renard   Add process to te...
58
59
60
61
62
	/*
	 * @brief Load a CSV file (with ; as columns separator)
	 */
	static std::vector<std::vector<std::string> > loadCSVFile(const char* filePath, char colSeparator);

fbe3c2bb   Benjamin Renard   First commit
63
64
65
66
67
68
69
70
71
72
73
74
75
76
	/**
	 * @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_ */