1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/io/nsIScriptableInputStream.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsISupports.idl" 1.10 + 1.11 +interface nsIInputStream; 1.12 + 1.13 +/** 1.14 + * nsIScriptableInputStream provides scriptable access to an nsIInputStream 1.15 + * instance. 1.16 + */ 1.17 +[scriptable, uuid(3fce9015-472a-4080-ac3e-cd875dbe361e)] 1.18 +interface nsIScriptableInputStream : nsISupports 1.19 +{ 1.20 + /** 1.21 + * Closes the stream. 1.22 + */ 1.23 + void close(); 1.24 + 1.25 + /** 1.26 + * Wrap the given nsIInputStream with this nsIScriptableInputStream. 1.27 + * 1.28 + * @param aInputStream parameter providing the stream to wrap 1.29 + */ 1.30 + void init(in nsIInputStream aInputStream); 1.31 + 1.32 + /** 1.33 + * Return the number of bytes currently available in the stream 1.34 + * 1.35 + * @return the number of bytes 1.36 + * 1.37 + * @throws NS_BASE_STREAM_CLOSED if called after the stream has been closed 1.38 + */ 1.39 + unsigned long long available(); 1.40 + 1.41 + /** 1.42 + * Read data from the stream. 1.43 + * 1.44 + * WARNING: If the data contains a null byte, then this method will return 1.45 + * a truncated string. 1.46 + * 1.47 + * @param aCount the maximum number of bytes to read 1.48 + * 1.49 + * @return the data, which will be an empty string if the stream is at EOF. 1.50 + * 1.51 + * @throws NS_BASE_STREAM_CLOSED if called after the stream has been closed 1.52 + * @throws NS_ERROR_NOT_INITIALIZED if init was not called 1.53 + */ 1.54 + string read(in unsigned long aCount); 1.55 + 1.56 + /** 1.57 + * Read data from the stream, including NULL bytes. 1.58 + * 1.59 + * @param aCount the maximum number of bytes to read. 1.60 + * 1.61 + * @return the data from the stream, which will be an empty string if EOF 1.62 + * has been reached. 1.63 + * 1.64 + * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from the input stream 1.65 + * would block the calling thread (non-blocking mode only). 1.66 + * @throws NS_ERROR_FAILURE if there are not enough bytes available to read 1.67 + * aCount amount of data. 1.68 + */ 1.69 + ACString readBytes(in unsigned long aCount); 1.70 +};