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.
Returns the total length of the stream if known. Otherwise it returns -1. This is different than calling available() which returns the number of bytes ready to be read from the stream. -1 is a valid value for a stream that doesn't know its length. For instance, a pipe stream could return such value.
It could throw NS_BASE_STREAM_WOULD_BLOCK if the inputStream is non-blocking. If this happens, you should use nsIAsyncInputStreamLength::asyncLengthWait().
If the stream has already been read (read()/readSegments()/close()/seek() methods has been called), length() returns NS_ERROR_NOT_AVAILABLE.
This is not an attribute because a stream can change its length. For instance, if the stream is a file inputStream and the underlying OS file changes, its length will change as well.
Generated using TypeDoc
Note: Instead of using these interfaces directly, consider to use InputStreamLengthHelper class.