-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.h
More file actions
47 lines (43 loc) · 1.64 KB
/
Copy pathtools.h
File metadata and controls
47 lines (43 loc) · 1.64 KB
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
/*
* tools.h
*
* Created on: 16.01.2015
* Author: oliver
*/
#ifndef TOOLS_H_
#define TOOLS_H_
#include <iostream>
#include <vector>
#include <sstream>
#include <iomanip>
#include <sys/time.h>
#define COMMANDSFILE std::string(getenv("HOME")) + "/tmp/commands.txt"
std::string boolToStr(bool var);
FILE * popen2(std::string command, std::string type, int & pid);
int pclose2(FILE * fp, pid_t pid);
std::string string_replace(std::string src, std::string const& target, std::string const& repl);
std::string execToString(std::string command);
std::string execDisplayToString(std::string command);
std::vector<std::string> split(std::string org, std::string separator);
void logline(std::string log, bool active);
std::string numToString(float number, int precision = 0);
std::string toUTF8(std::string str);
int strfind(std::string str, std::string query);
std::string decode(std::string str);
int getProcIdByName(std::string procName);
std::string readFile(std::string filename, bool *success = NULL);
double timevalDelta(timeval end, timeval start);
void deleteFile(std::string filename);
void deleteOld(std::string directory, int number);
void deleteFolder(std::string foldername);
void writeToFile(std::string content, std::string file, bool append);
std::string dbus(std::string service, std::string path, std::string method,
bool *success = NULL);
std::string changeFormat(std::string str);
int getUTime(int pid);
float avgCPULoad(float time);
bool waitLoad(float maxLoad, float time, bool log, float timeout, int AVGConsiderLast,
std::string reason = "");
void mkdir(std::string folder);
bool is_file_exist(std::string fileName);
#endif /* TOOLS_H_ */