|
|
@ -76,19 +76,20 @@ std::string read_file(const std::string& fn) { |
|
|
|
return std::string(); |
|
|
|
return std::string(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int read_files_in_dir(const std::string &path, std::map<std::string, std::string> *contents) { |
|
|
|
std::map<std::string, std::string> read_files_in_dir(const std::string &path) { |
|
|
|
|
|
|
|
std::map<std::string, std::string> ret; |
|
|
|
DIR *d = opendir(path.c_str()); |
|
|
|
DIR *d = opendir(path.c_str()); |
|
|
|
if (!d) return -1; |
|
|
|
if (!d) return ret; |
|
|
|
|
|
|
|
|
|
|
|
struct dirent *de = NULL; |
|
|
|
struct dirent *de = NULL; |
|
|
|
while ((de = readdir(d))) { |
|
|
|
while ((de = readdir(d))) { |
|
|
|
if (isalnum(de->d_name[0])) { |
|
|
|
if (isalnum(de->d_name[0])) { |
|
|
|
(*contents)[de->d_name] = util::read_file(path + "/" + de->d_name); |
|
|
|
ret[de->d_name] = util::read_file(path + "/" + de->d_name); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
closedir(d); |
|
|
|
closedir(d); |
|
|
|
return 0; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int write_file(const char* path, const void* data, size_t size, int flags, mode_t mode) { |
|
|
|
int write_file(const char* path, const void* data, size_t size, int flags, mode_t mode) { |
|
|
|