1 /* -*- Mode: IDL; 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/. */
6 #include
"nsISupports.idl"
8 interface nsIInputStream
;
11 * nsIScriptableInputStream provides scriptable access to an nsIInputStream
14 [scriptable
, uuid(3fce9015
-472a
-4080-ac3e
-cd875dbe361e
)]
15 interface nsIScriptableInputStream
: nsISupports
23 * Wrap the given nsIInputStream with this nsIScriptableInputStream.
25 * @param aInputStream parameter providing the stream to wrap
27 void init
(in nsIInputStream aInputStream
);
30 * Return the number of bytes currently available in the stream
32 * @return the number of bytes
34 * @throws NS_BASE_STREAM_CLOSED if called after the stream has been closed
36 unsigned long long available
();
39 * Read data from the stream.
41 * WARNING: If the data contains a null byte, then this method will return
44 * @param aCount the maximum number of bytes to read
46 * @return the data, which will be an empty string if the stream is at EOF.
48 * @throws NS_BASE_STREAM_CLOSED if called after the stream has been closed
49 * @throws NS_ERROR_NOT_INITIALIZED if init was not called
51 string read
(in unsigned long aCount
);
54 * Read data from the stream, including NULL bytes.
56 * @param aCount the maximum number of bytes to read.
58 * @return the data from the stream, which will be an empty string if EOF
61 * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from the input stream
62 * would block the calling thread (non-blocking mode only).
63 * @throws NS_ERROR_FAILURE if there are not enough bytes available to read
64 * aCount amount of data.
66 ACString readBytes
(in unsigned long aCount
);