michael@0: /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIInputStream; michael@0: michael@0: /** michael@0: * nsIScriptableInputStream provides scriptable access to an nsIInputStream michael@0: * instance. michael@0: */ michael@0: [scriptable, uuid(3fce9015-472a-4080-ac3e-cd875dbe361e)] michael@0: interface nsIScriptableInputStream : nsISupports michael@0: { michael@0: /** michael@0: * Closes the stream. michael@0: */ michael@0: void close(); michael@0: michael@0: /** michael@0: * Wrap the given nsIInputStream with this nsIScriptableInputStream. michael@0: * michael@0: * @param aInputStream parameter providing the stream to wrap michael@0: */ michael@0: void init(in nsIInputStream aInputStream); michael@0: michael@0: /** michael@0: * Return the number of bytes currently available in the stream michael@0: * michael@0: * @return the number of bytes michael@0: * michael@0: * @throws NS_BASE_STREAM_CLOSED if called after the stream has been closed michael@0: */ michael@0: unsigned long long available(); michael@0: michael@0: /** michael@0: * Read data from the stream. michael@0: * michael@0: * WARNING: If the data contains a null byte, then this method will return michael@0: * a truncated string. michael@0: * michael@0: * @param aCount the maximum number of bytes to read michael@0: * michael@0: * @return the data, which will be an empty string if the stream is at EOF. michael@0: * michael@0: * @throws NS_BASE_STREAM_CLOSED if called after the stream has been closed michael@0: * @throws NS_ERROR_NOT_INITIALIZED if init was not called michael@0: */ michael@0: string read(in unsigned long aCount); michael@0: michael@0: /** michael@0: * Read data from the stream, including NULL bytes. michael@0: * michael@0: * @param aCount the maximum number of bytes to read. michael@0: * michael@0: * @return the data from the stream, which will be an empty string if EOF michael@0: * has been reached. michael@0: * michael@0: * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from the input stream michael@0: * would block the calling thread (non-blocking mode only). michael@0: * @throws NS_ERROR_FAILURE if there are not enough bytes available to read michael@0: * aCount amount of data. michael@0: */ michael@0: ACString readBytes(in unsigned long aCount); michael@0: };