Note that there are some explanatory texts on larger screens.

plurals
  1. POLoaded data truncated when using nsIFileInputStream & nsIConverterInputStream
    primarykey
    data
    text
    <p>I'm working on a project (BrowserIO - go to browserio dot googlecode dot com if you want to check out the code and work on it. Help welcome!) in which I'm using Firefox's nsIFileInputStream in tandem with nsIConverterInputStream, per their example (<a href="https://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO#Simple" rel="nofollow noreferrer">https://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO#Simple</a>), but only a portion of the full data is being loaded. The code is:</p> <pre><code>var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(path); var data = ""; var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); var cstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"].createInstance(Components.interfaces.nsIConverterInputStream); fstream.init(file, -1, 0, 0); cstream.init(fstream, "UTF-8", 0, 0); // you can use another encoding here if you wish var str = {}; cstream.readString(-1, str); // read the whole file and put it in str.value data = str.value; cstream.close(); // this closes fstream </code></pre> <p>If you want to see this behavior, checkout the code from the BrowserIO project page, and use Firebug to set a breakpoint at the <code>data = str.value;</code> line in file_io.js. Then select a text file from the list, and click the "Open" button. In Firebug, in the watch panel set a watch for str.value. Look at the file... It should be truncated, unless it's really short.</p> <p>For reference, the code above is the main body of the openFile() function in trunk/scripts/file_io.js.</p> <p>Anybody have any clue what's happening with this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload