Bug 360930 - test_file_protocol.js can fail based on execution environment (where TmpD contains a particularly large number of files). r+sr=biesi

This commit is contained in:
jwalden%mit.edu 2006-11-16 21:44:46 +00:00
Родитель 29f6eab17a
Коммит 6dcb43a12a
1 изменённых файлов: 12 добавлений и 7 удалений

Просмотреть файл

@ -33,13 +33,18 @@ function read_stream(stream, count) {
Cc["@mozilla.org/binaryinputstream;1"].
createInstance(Ci.nsIBinaryInputStream);
wrapper.setInputStream(stream);
var bytes = wrapper.readByteArray(count);
/* assume that the stream is going to give us all of the data.
not all streams conform to this. */
if (bytes.length != count)
do_throw("Partial read from input stream!");
/* convert array of bytes to a String object (by no means efficient) */
return eval("String.fromCharCode(" + bytes.toString() + ")");
/* JS methods can be called with a maximum of 65535 arguments, and input
streams don't have to return all the data they make .available() when
asked to .read() that number of bytes. */
var data = [];
while (count > 0) {
var bytes = wrapper.readByteArray(Math.min(65535, count));
data.push(String.fromCharCode.apply(null, bytes));
count -= bytes.length;
if (bytes.length == 0)
do_throw("Nothing read from input stream!");
}
return data.join('');
}
function new_file_input_stream(file, buffered) {