|
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 const enablePrivilege = netscape.security.PrivilegeManager.enablePrivilege; |
|
7 const IOSERVICE_CTRID = "@mozilla.org/network/io-service;1"; |
|
8 const nsIIOService = Components.interfaces.nsIIOService; |
|
9 const SIS_CTRID = "@mozilla.org/scriptableinputstream;1"; |
|
10 const nsISIS = Components.interfaces.nsIScriptableInputStream; |
|
11 const nsIFilePicker = Components.interfaces.nsIFilePicker; |
|
12 const STDURL_CTRID = "@mozilla.org/network/standard-url;1"; |
|
13 const nsIURI = Components.interfaces.nsIURI; |
|
14 |
|
15 var gStop = false; |
|
16 |
|
17 function loadFile(aUriSpec) |
|
18 { |
|
19 enablePrivilege('UniversalXPConnect'); |
|
20 var serv = Components.classes[IOSERVICE_CTRID]. |
|
21 getService(nsIIOService); |
|
22 if (!serv) { |
|
23 throw Components.results.ERR_FAILURE; |
|
24 } |
|
25 var chan = serv.newChannel(aUriSpec, null, null); |
|
26 var instream = |
|
27 Components.classes[SIS_CTRID].createInstance(nsISIS); |
|
28 instream.init(chan.open()); |
|
29 |
|
30 return instream.read(instream.available()); |
|
31 } |
|
32 |
|
33 function dump20(aVal) |
|
34 { |
|
35 const pads = ' '; |
|
36 if (typeof(aVal)=='string') |
|
37 out = aVal; |
|
38 else if (typeof(aVal)=='number') |
|
39 out = Number(aVal).toFixed(2); |
|
40 else |
|
41 out = new String(aVal); |
|
42 dump(pads.substring(0, 20 - out.length)); |
|
43 dump(out); |
|
44 } |