| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#ifndef UTIL_H |
| 18 |
#define UTIL_H |
| 19 |
|
| 20 |
#include <sys/types.h> |
| 21 |
|
| 22 |
#include <map> |
| 23 |
#include <string> |
| 24 |
#include <vector> |
| 25 |
|
| 26 |
using namespace std; |
| 27 |
|
| 28 |
struct FileInfo |
| 29 |
{ |
| 30 |
bool exists; |
| 31 |
time_t mtime; |
| 32 |
time_t ctime; |
| 33 |
off_t size; |
| 34 |
|
| 35 |
FileInfo(); |
| 36 |
FileInfo(const FileInfo& that); |
| 37 |
explicit FileInfo(const string& filename); |
| 38 |
~FileInfo(); |
| 39 |
|
| 40 |
bool operator==(const FileInfo& that) const; |
| 41 |
bool operator!=(const FileInfo& that) const; |
| 42 |
}; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
struct TrackedFile { |
| 49 |
string filename; |
| 50 |
FileInfo fileInfo; |
| 51 |
|
| 52 |
TrackedFile(); |
| 53 |
TrackedFile(const TrackedFile& that); |
| 54 |
explicit TrackedFile(const string& filename); |
| 55 |
~TrackedFile(); |
| 56 |
|
| 57 |
|
| 58 |
bool HasChanged() const; |
| 59 |
}; |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
void get_directory_contents(const string& dir, map<string,FileInfo>* results); |
| 66 |
|
| 67 |
bool directory_contents_differ(const map<string,FileInfo>& before, |
| 68 |
const map<string,FileInfo>& after); |
| 69 |
|
| 70 |
string escape_quotes(const char* str); |
| 71 |
|
| 72 |
string escape_for_commandline(const char* str); |
| 73 |
|
| 74 |
string trim(const string& trim); |
| 75 |
|
| 76 |
bool starts_with(const string& str, const string& prefix); |
| 77 |
|
| 78 |
bool ends_with(const string& str, const string& suffix); |
| 79 |
|
| 80 |
void split_lines(vector<string>* result, const string& str); |
| 81 |
|
| 82 |
string read_file(const string& filename); |
| 83 |
|
| 84 |
bool is_executable(const string& filename); |
| 85 |
|
| 86 |
string dirname(const string& filename); |
| 87 |
string leafname(const string& filename); |
| 88 |
|
| 89 |
#endif |
| 90 |
|