Optional
aInstancePtr: objectA run time mechanism for interface discovery.
NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.
aInstancePtr must not be null.
[in] A requested interface IID
[out] A pointer to an interface pointer to receive the result.
Close the stream. Forces the output stream to flush any buffered data. Any subsequent calls to StreamStatus should throw NS_BASE_STREAM_CLOSED. Succeeds without effect if already closed.
NS_BASE_STREAM_WOULD_BLOCK if unable to flush without blocking the calling thread (non-blocking mode only)
file to write to
file open flags listed in prio.h (see PR_Open documentation) or -1 to open the file in default mode (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE)
file mode bits listed in prio.h or -1 to use the default permissions (0664)
flags specifying various behaviors of the class (currently none supported)
true if stream is non-blocking
NOTE: writing to a blocking output stream will block the calling thread until all given data can be consumed by the stream.
NOTE: a non-blocking output stream may implement nsIAsyncOutputStream to provide consumers with a way to wait for the stream to accept more data once its write method is unable to accept any data without blocking.
NS_ERROR_FAILURE if the preallocation fails.
NS_ERROR_NOT_INITIALIZED if the file is not opened.
asks the operating system to allocate storage for this file of at least |length| bytes long, and set the file length to the corresponding size.
Check the current status of the stream. A stream that is closed will throw an exception when this method is called. That enables the caller to know the condition of the stream before attempting to write into it.
This method will not throw NS_BASE_STREAM_WOULD_BLOCK, even if the stream is a non-blocking stream with no available space. A non-blocking stream which has not been closed, but has no available room should return NS_OK.
NOTE: This method should not block the calling thread (e.g. to query the state of a file descriptor), even when called on a blocking stream.
NS_BASE_STREAM_CLOSED if the stream closed normally
Write data into the stream.
number of bytes written (may be less than aCount)
NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would block the calling thread (non-blocking mode only)
the buffer containing the data to be written
the maximum number of bytes to be written
Writes data into the stream from an input stream.
number of bytes written (may be less than aCount)
NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would block the calling thread (non-blocking mode only). This failure means no bytes were transferred.
NOTE: This method is defined by this interface in order to allow the output stream to efficiently copy the data from the input stream into its internal buffer (if any). If this method was provided as an external facility, a separate char* buffer would need to be used in order to call the output stream's other Write method.
the stream containing the data to be written
the maximum number of bytes to be written
Low-level write method that has access to the stream's underlying buffer. The reader function may be called multiple times for segmented buffers. WriteSegments is expected to keep calling the reader until either there is nothing left to write or the reader returns an error. WriteSegments should not call the reader with zero bytes to provide.
number of bytes written (may be less than aCount)
NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would block the calling thread (non-blocking mode only). This failure means no bytes were transferred.
NS_ERROR_NOT_IMPLEMENTED if the stream has no underlying buffer
NOTE: this function may be unimplemented if a stream has no underlying buffer (e.g., socket output stream).
the "provider" of the data to be written
opaque parameter passed to reader
the maximum number of bytes to be written
Generated using TypeDoc
An output stream that lets you stream to a file.