some file IO related xpcom. misc
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 8 Sep 2005 20:38:37 +0000 (20:38 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 8 Sep 2005 20:38:37 +0000 (20:38 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1814 dcc99617-32d9-48b4-a31d-7c20da2025e4

Evergreen/staff_client/chrome/content/evergreen/util/error.js
Evergreen/staff_client/chrome/content/evergreen/util/file.js [new file with mode: 0644]
Evergreen/staff_client/chrome/content/evergreen/util/util_overlay.xul

index 7d82039..f74423e 100644 (file)
@@ -40,14 +40,14 @@ var sdump_levels = {
 
        'D_PATRON_ITEMS' : false,
        'D_PATRON_CHECKOUT_ITEMS' : false,
-       'D_PATRON_HOLDS' : true,
+       'D_PATRON_HOLDS' : false,
        'D_PATRON_BILLS' : false,
        'D_PATRON_EDIT' : false,
 
-       'D_CHECKIN' : true,
+       'D_CHECKIN' : false,
        'D_CHECKIN_ITEMS' : false,
 
-       'D_HOLD_CAPTURE' : true,
+       'D_HOLD_CAPTURE' : false,
        'D_HOLD_CAPTURE_ITEMS' : false,
 
        'D_CAT' : false,
@@ -57,7 +57,7 @@ var sdump_levels = {
 
        'D_EXPLODE' : false,
        'D_FM_UTILS' : false,
-       'D_PRINT' : true,
+       'D_PRINT' : false,
        'D_SES' : true,
        'D_SES_FUNC' : false,
        'D_SES_RESULT' : true,
diff --git a/Evergreen/staff_client/chrome/content/evergreen/util/file.js b/Evergreen/staff_client/chrome/content/evergreen/util/file.js
new file mode 100644 (file)
index 0000000..30cc7e2
--- /dev/null
@@ -0,0 +1,51 @@
+sdump('D_TRACE','Loading file.js\n');
+
+var dirService = Components.classes["@mozilla.org/file/directory_service;1"].
+       getService( Components.interfaces.nsIProperties );
+
+function create_input_stream(file) {
+       try {
+               if (typeof(file)=='string') file = get_file( file );
+               var f = Components.classes["@mozilla.org/network/file-input-stream;1"]
+                       .createInstance(Components.interfaces.nsIFileInputStream);
+               if (file && file.exists()) {
+                       f.init(file, 0x01, 0, 0);
+                       var s = Components.classes["@mozilla.org/scriptableinputstream;1"]
+                               .createInstance(Components.interfaces.nsIScriptableInputStream);
+                       if (f) {
+                               s.init(f);
+                               return s;
+                       }
+               }
+       } catch(E) {
+               sdump('D_ERROR', E);
+       }
+       return null;
+}
+
+function create_output_stream(file) {
+       try {
+               if (typeof(file)=='string') file = get_file( file );
+               var f = Components.classes["@mozilla.org/network/file-output-stream;1"]
+                       .createInstance(Components.interfaces.nsIFileOutputStream);
+               if (file) {
+                       if (! file.exists()) file.create( 0, 0640 );
+                       f.init(file, 0x02 | 0x08 | 0x20, 0644, 0);
+                       return f;
+               }
+       } catch(E) {
+               sdump('D_ERROR', E);
+       }
+       return null;
+}
+
+function get_file( fname ) {
+       try {
+               file = dirService.get( "AChrom",  Components.interfaces.nsIFile );
+               file.append(mw.myPackageDir); file.append("content"); file.append("conf"); file.append("fname");
+               return file;
+       } catch(E) {
+               sdump('D_ERROR', E);
+               return null;
+       }
+}
index d841c7b..66e075a 100644 (file)
@@ -13,6 +13,7 @@
 
        <script src="error.js" />       <!-- more like output handling -->
        <script src="util.js" />        <!-- miscellaneous scripts.  want to make this empty -->
+       <script src="file.js" />        <!-- file IO -->
        <script src="datetime.js" />    <!-- date & time related functions -->
        <script src="functional.js" />  <!-- neat use of first-class functions, and some predecessors -->
        <script src="fm_utils.js" />    <!-- some convenience functions for fieldmapper objects -->