Directly log to log file

This commit is contained in:
topjohnwu
2020-12-03 20:15:18 -08:00
parent 797ba4fbf4
commit f152e8c33d
6 changed files with 87 additions and 52 deletions

View File

@@ -353,7 +353,7 @@ void file_readline(bool trim, const char *file, const function<bool(string_view)
free(buf);
}
void parse_prop_file(const char *file, const function<bool(string_view, string_view)> &&fn) {
void parse_prop_file(const char *file, const function<bool(string_view, string_view)> &fn) {
file_readline(true, file, [&](string_view line_view) -> bool {
char *line = (char *) line_view.data();
if (line[0] == '#')
@@ -422,3 +422,11 @@ void restore_folder(const char *dir, vector<raw_file> &files) {
setattr(path.data(), &file.attr);
}
}
sDIR make_dir(DIR *dp) {
return sDIR(dp, [](DIR *dp){ return dp ? closedir(dp) : 1; });
}
sFILE make_file(FILE *fp) {
return sFILE(fp, [](FILE *fp){ return fp ? fclose(fp) : 1; });
}