autoconfig: add write_line() helper func

This commit is contained in:
Oliver Smith 2023-04-06 19:20:36 +00:00
parent fe45bbc8dc
commit 1b0c066793
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -24,10 +24,15 @@ logFile.append("mobile-config-firefox.log");
var mode = FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_APPEND; var mode = FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_APPEND;
var logFileStream = FileUtils.openFileOutputStream(logFile, mode); var logFileStream = FileUtils.openFileOutputStream(logFile, mode);
function write_line(ostream, line) {
line = line + "\n"
ostream.write(line, line.length);
}
function log(line) { function log(line) {
var date = new Date().toISOString().replace("T", " ").slice(0, 19); var date = new Date().toISOString().replace("T", " ").slice(0, 19);
line = "[" + date + "] " + line + "\n"; line = "[" + date + "] " + line;
logFileStream.write(line, line.length); write_line(logFileStream, line);
} }
// Debug function for logging object attributes // Debug function for logging object attributes
@ -160,8 +165,7 @@ function css_file_merge(name, file) {
var line; var line;
var fragment = fragments[i]; var fragment = fragments[i];
log("- " + fragment); log("- " + fragment);
line = "/* === " + fragment + " === */\n" write_line(ostream, "/* === " + fragment + " === */");
ostream.write(line, line.length);
var file_fragment = new FileUtils.File(fragment); var file_fragment = new FileUtils.File(fragment);
@ -174,8 +178,7 @@ function css_file_merge(name, file) {
do { do {
var line = {}; var line = {};
has_more = istream.readLine(line); has_more = istream.readLine(line);
line = line.value + "\n"; write_line(ostream, line.value);
ostream.write(line, line.length);
} while (has_more); } while (has_more);
istream.close(); istream.close();