dump('Loading constants.js\n');
+const MODE_RDONLY = 0x01;
+const MODE_WRONLY = 0x02;
+const MODE_CREATE = 0x08;
+const MODE_APPEND = 0x10;
+const MODE_TRUNCATE = 0x20;
+const MODE_SYNC = 0x40;
+const MODE_EXCL = 0x80;
+const PERMS_FILE = 0644;
+const PERMS_DIR = 0755;
+
const my_constants = {
'magical_statuses' : {
'1' : { 'disable_in_copy_editor' : true, 'block_mark_item_action' : true }, /* | Checked out | t */
this._f = Components.classes["@mozilla.org/network/file-input-stream;1"]
.createInstance(Components.interfaces.nsIFileInputStream);
- this._f.init(this._file, 0x01, 0, 0);
+ this._f.init(this._file, MODE_RDONLY, 0, 0);
/*
this._f.QueryInterface(Components.interfaces.nsILineInputStream);
this._istream = this._f;
'_create_output_stream' : function(param) {
try {
- //dump('_create_output_stream('+param+')\n');
+ //dump('_create_output_stream('+param+') for '+this._file.path+'\n');
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead");
if (!this._file) throw('Must .get() a file first.');
- if (! this._file.exists()) this._file.create( 0, 0640 );
-
+ if (! this._file.exists()) {
+ if (param == 'truncate+exec') {
+ this._file.create( 0, 0777 );
+ } else {
+ this._file.create( 0, PERMS_FILE );
+ }
+ }
this._output_stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance(Components.interfaces.nsIFileOutputStream);
switch(param){
case 'append' :
- this._output_stream.init(this._file, 0x02 | 0x08 | 0x10 | 0x40, 0644, 0);
+ this._output_stream.init(this._file, MODE_WRONLY | MODE_APPEND, PERMS_FILE, 0);
break;
+ case 'truncate+exec' :
+ this._output_stream.init(this._file, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, 0);
+ break;
case 'truncate' :
default:
- this._output_stream.init(this._file, 0x02 | 0x08 | 0x20 | 0x40, 0644, 0);
+ this._output_stream.init(this._file, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, 0);
break;
}
var text = w;
var file = new util.file('receipt.txt');
- file.write_content('truncate',text); file.close();
+ file.write_content('truncate',text);
+ var path = file._file.path;
+ file.close();
file = new util.file('receipt.bat');
- if (! file._file.exists()) {
- file.write_content('truncate','copy chrome\\open_ils_staff_client\\content\\conf\\receipt.txt lpt1 /b\n');
- file.close();
- file = new util.file('receipt.bat');
- }
+ file.write_content('truncate+exec','#!/bin/sh\ncopy ' + path + ' lpt1 /b\nlpr ' + path + '\n');
+ file.close();
+ file = new util.file('receipt.bat');
var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
process.init(file._file);
var args = [];
- process.run(true, args, args.length);
+ dump('process.run = ' + process.run(true, args, args.length) + '\n');
+
+ file.close();
} catch (e) {
//alert('Probably not printing: ' + e);