Skip to content
Snippets Groups Projects
Commit b29f0fa8 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Replace print() with writeln()

parent 4baf1a3d
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #1871 passed
...@@ -13,22 +13,22 @@ const default_excludes = [ ...@@ -13,22 +13,22 @@ const default_excludes = [
]; ];
if(argv.indexOf("-help") >= 0 || argv.indexOf("-?") >= 0) { if(argv.indexOf("-help") >= 0 || argv.indexOf("-?") >= 0) {
print("usage: [-options] [dir-code] [listfile]"); writeln("usage: [-options] [dir-code] [listfile]");
print("options:"); writeln("options:");
print("-all add files in all libraries/directories (implies -auto)"); writeln(" -all add files in all libraries/directories (implies -auto)");
print("-lib=<name> add files in all directories of specified library (implies -auto)"); writeln(" -lib=<name> add files in all directories of specified library (implies -auto)");
print("-from=<name> specify uploader's user name (may require quotes)"); writeln(" -from=<name> specify uploader's user name (may require quotes)");
print("-ex=<filename> add to excluded filename list"); writeln(" -ex=<filename> add to excluded filename list");
print(" (default: " + default_excludes.join(',') + ")"); writeln(" (default: " + default_excludes.join(',') + ")");
print("-diz always extract/use description in archive"); writeln(" -diz always extract/use description in archive");
print("-update update existing file entries (default is to skip them)"); writeln(" -update update existing file entries (default is to skip them)");
print("-date[=fmt] include today's date in description"); writeln(" -date[=fmt] include today's date in description");
print("-fdate[=fmt] include file's date in description"); writeln(" -fdate[=fmt] include file's date in description");
print("-adate[=fmt] include newest archived file date in description"); writeln(" -adate[=fmt] include newest archived file date in description");
print(" (fmt = optional strftime date/time format string)"); writeln(" (fmt = optional strftime date/time format string)");
print("-delete delete list after import"); writeln(" -delete delete list after import");
print("-v increase verbosity of output"); writeln(" -v increase verbosity of output");
print("-debug enable debug output"); writeln(" -debug enable debug output");
exit(0); exit(0);
} }
...@@ -126,7 +126,7 @@ if(!dir_list.length) { ...@@ -126,7 +126,7 @@ if(!dir_list.length) {
var code; var code;
while(!file_area.dir[code] && !js.terminated) { while(!file_area.dir[code] && !js.terminated) {
for(var d in file_area.dir) for(var d in file_area.dir)
print(d); writeln(d);
code = prompt("Directory code"); code = prompt("Directory code");
} }
dir_list.push(code); dir_list.push(code);
...@@ -144,7 +144,7 @@ for(var d = 0; d < dir_list.length; d++) { ...@@ -144,7 +144,7 @@ for(var d = 0; d < dir_list.length; d++) {
} }
if(options.auto && (dir.settings & DIR_NOAUTO)) if(options.auto && (dir.settings & DIR_NOAUTO))
continue; continue;
print("Adding files to " + dir.lib_name + " " + dir.name); writeln("Adding files to " + dir.lib_name + " " + dir.name);
var filebase = new FileBase(code); var filebase = new FileBase(code);
if(!filebase.open("r")) { if(!filebase.open("r")) {
...@@ -157,7 +157,7 @@ for(var d = 0; d < dir_list.length; d++) { ...@@ -157,7 +157,7 @@ for(var d = 0; d < dir_list.length; d++) {
for(var i = 0; i < name_list.length; i++) { for(var i = 0; i < name_list.length; i++) {
name_list[i] = name_list[i].toUpperCase(); name_list[i] = name_list[i].toUpperCase();
if(options.debug) if(options.debug)
print(name_list[i]); writeln(name_list[i]);
} }
var file_list = []; var file_list = [];
...@@ -166,7 +166,7 @@ for(var d = 0; d < dir_list.length; d++) { ...@@ -166,7 +166,7 @@ for(var d = 0; d < dir_list.length; d++) {
listpath = file_getcase(dir.path + listfile) || file_getcase(listfile); listpath = file_getcase(dir.path + listfile) || file_getcase(listfile);
var f = new File(listpath); var f = new File(listpath);
if(f.exists) { if(f.exists) {
print("Opening " + f.name); writeln("Opening " + f.name);
if(!f.open('r')) { if(!f.open('r')) {
alert("Error " + f.error + " (" + strerror(f.error) + ") opening " + f.name); alert("Error " + f.error + " (" + strerror(f.error) + ") opening " + f.name);
exit(1); exit(1);
...@@ -190,21 +190,21 @@ for(var d = 0; d < dir_list.length; d++) { ...@@ -190,21 +190,21 @@ for(var d = 0; d < dir_list.length; d++) {
var file = file_list[i]; var file = file_list[i];
file.from = uploader; file.from = uploader;
if(options.debug) if(options.debug)
print(JSON.stringify(file, null, 4)); writeln(JSON.stringify(file, null, 4));
else if(verbosity) else if(verbosity)
printf("%s ", file.name); write(file.name + " ");
if(exclude.indexOf(file.name.toUpperCase()) >= 0) { if(exclude.indexOf(file.name.toUpperCase()) >= 0) {
if(verbosity) if(verbosity)
print("excluded (ignored)"); writeln("excluded (ignored)");
continue; continue;
} }
file.extdesc = lfexpand(file.extdesc); file.extdesc = lfexpand(file.extdesc);
if(verbosity > 1) if(verbosity > 1)
print(JSON.stringify(file)); writeln(JSON.stringify(file));
var exists = name_list.indexOf(filebase.get_name(file.name).toUpperCase()) >= 0; var exists = name_list.indexOf(filebase.get_name(file.name).toUpperCase()) >= 0;
if(exists && !options.update) { if(exists && !options.update) {
if(verbosity) if(verbosity)
print("already added"); writeln("already added");
continue; continue;
} }
var path = file_area.dir[code].path + file.name; var path = file_area.dir[code].path + file.name;
...@@ -231,7 +231,7 @@ for(var d = 0; d < dir_list.length; d++) { ...@@ -231,7 +231,7 @@ for(var d = 0; d < dir_list.length; d++) {
if(!filebase.update(file.name, file, options.diz)) { if(!filebase.update(file.name, file, options.diz)) {
alert("Error " + filebase.last_error + " updating " + file.name); alert("Error " + filebase.last_error + " updating " + file.name);
} else { } else {
print("Updated " + file.name); writeln("Updated " + file.name);
updated++; updated++;
} }
} else { } else {
...@@ -239,24 +239,24 @@ for(var d = 0; d < dir_list.length; d++) { ...@@ -239,24 +239,24 @@ for(var d = 0; d < dir_list.length; d++) {
if(!filebase.add(file, options.diz)) { if(!filebase.add(file, options.diz)) {
alert("Error " + filebase.last_error + " adding " + file.name); alert("Error " + filebase.last_error + " adding " + file.name);
} else { } else {
print("Added " + file.name); writeln("Added " + file.name);
added++; added++;
} }
} }
} }
if(listpath && options.delete) { if(listpath && options.delete) {
if(verbosity) if(verbosity)
print("Deleting list file: " + listpath); writeln("Deleting list file: " + listpath);
if(file_remove(listpath)) if(file_remove(listpath))
print("List file deleted: " + listpath); writeln("List file deleted: " + listpath);
else else
alert("Failed to delete list file: " + listpath); alert("Failed to delete list file: " + listpath);
} }
filebase.close(); filebase.close();
} }
print(added + " files added"); writeln(added + " files added");
if(updated) if(updated)
print(updated + " files updated"); writeln(updated + " files updated");
// Parse a FILES.BBS (or similar) file listing file // Parse a FILES.BBS (or similar) file listing file
// Note: file descriptions must begin with an alphabetic character // Note: file descriptions must begin with an alphabetic character
...@@ -266,7 +266,7 @@ function parse_file_list(lines) ...@@ -266,7 +266,7 @@ function parse_file_list(lines)
for(var i = 0; i < lines.length; i++) { for(var i = 0; i < lines.length; i++) {
var line = lines[i]; var line = lines[i];
var match = line.match(/(^[\w]+[\w\-\!\#\.]*)\W+[^A-Za-z]*(.*)/); var match = line.match(/(^[\w]+[\w\-\!\#\.]*)\W+[^A-Za-z]*(.*)/);
// print('fname line match: ' + JSON.stringify(match)); // writeln('fname line match: ' + JSON.stringify(match));
if(match && match.length > 1) { if(match && match.length > 1) {
var file = { name: match[1], desc: match[2] }; var file = { name: match[1], desc: match[2] };
if(file.desc && file.desc.length > LEN_FDESC) if(file.desc && file.desc.length > LEN_FDESC)
...@@ -280,7 +280,7 @@ function parse_file_list(lines) ...@@ -280,7 +280,7 @@ function parse_file_list(lines)
alert("Ignoring line: " + line); alert("Ignoring line: " + line);
continue; continue;
} }
// print('match: ' + JSON.stringify(match)); // writeln('match: ' + JSON.stringify(match));
if(match && match.length > 1 && file_list.length) { if(match && match.length > 1 && file_list.length) {
var file = file_list[file_list.length - 1]; var file = file_list[file_list.length - 1];
if(!file.extdesc) if(!file.extdesc)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment