you'll need to use nsIScriptableInputStream to allow JS code to read from a nsIInputStream. e.g.:

http://lxr.mozilla.org/mozilla/source/extensions/irc/js/lib/connection-xpcom.js#45

darin



Fournier Daniel wrote:
Darin Fisher wrote:

> Axel Hecht wrote:
>
>> Hi,
>> after Darin's recent check-in, lot's of folks are confused how to write to a file from js. I guess most folks have wholeheartly copied jslib, which used the file-transport-service.
>> That obviously died (though the contract id is still in nsNetCID.h).
>>
>> I looked a tad around and found
>> "@mozilla.org/network/file-output-stream;1", but that seems to be new.
>>
>> Could someone suggest the "good way" to write to a file, working on builds both prior and after that check-in?
>>
>> Thanx
>>
>> Axel
>>
>
>
>
> "@mozilla.org/network/file-output-stream;1" -> nsIFileOutputStream
> "@mozilla.org/network/file-input-stream;1" -> nsIFileInputStream
>
> will work in all versions of mozilla since 1.0 (and probably well before that too). note: these interfaces and contract-ids are _NOT_ frozen. this means they may change in future versions of mozilla; however, i can say that i don't foresee any changes to these.
>
> if you need to asychronously read/write file streams, then you are stuck having to write code specific to mozilla 1.3 or previous versions.
>
> darin
>


Hi Darin,

Well, I'm one of those "confused folks" and desesperatly trying to fix the classes I wrote sometime ago and that worked till Mozilla 1.2.1.

How can you read from nsIFileInputStream since it inherits an *unscriptable* read method?

Cheers,

Daniel



Reply via email to