Files and Streams

The following interfaces are used to get information about local files and directories. Files can be read using input streams and written to using output streams. The main file interfaces is nsIFile and its subinterface nsILocalFile. You can open a file for reading and writing using the nsIFileIO interface, which inherits stream opening functions from the nsIStreamIO interface.

The network group also includes a number of additional stream reading and writing interfaces.

Jump to:


File Handling

the nsIFile interface is used for holding a file reference. You should always use an nsIFile rather than a string file path to ensure that your application will be portable. The nsIDirectoryServiceProvider interface can be used to get pointers to known system directories.

nsIDirectoryService
nsIDirectoryServiceProvider
nsIDirectoryServiceProvider2
nsIFile
nsIFileIO
nsIFileInputStream
nsIFileOutputStream
nsILocalFile
nsIStreamIO

@mozilla.org/directoryiterator;1
@mozilla.org/file/directory_service;1
@mozilla.org/file/local;1
@mozilla.org/filespec;1
@mozilla.org/network/file-input-stream;1
@mozilla.org/network/file-io;1
@mozilla.org/network/file-output-stream;1


Streams

Mozilla provides a number of stream interfaces which can be used for different purposes. The base interfaces nsIInputStream and nsIOutputStream provide methods for reading and writing respectively. Some components may support input only, output only or both input and output.

You can create a buffered reader or writer out of any other existing stream using nsIBufferedInputStream and nsIBufferedOutputStream. You can observe reading and writing to a stream using nsIObservableInputStream or nsIObservableOutputStream.

From script, you can use nsIScriptableInputStream to read from a stream. This interface will return strings.

nsIAsyncInputStream
nsIAsyncOutputStream
nsIBinaryInputStream
nsIBinaryOutputStream
nsIBufferedInputStream
nsIBufferedOutputStream
nsIByteArrayInputStream
nsIInputStream
nsIInputStreamCallback
nsIInputStreamIO
nsIInputStreamNotify
nsIInputStreamObserver
nsIInputStreamTee
nsILineInputStream
nsIMultiplexInputStream
nsIObjectInputStream
nsIObjectOutputStream
nsIObservableInputStream
nsIObservableOutputStream
nsIOutputStream
nsIOutputStreamCallback
nsIOutputStreamNotify
nsIOutputStreamObserver
nsIPipe
nsIScriptableInputStream
nsISearchableInputStream
nsISeekableStream
nsIStorageStream
nsIStreamBufferAccess
nsIStreamListener
nsIStreamListenerProxy
nsIStreamListenerTee
nsIStringInputStream

@mozilla.org/binaryinputstream;1
@mozilla.org/binaryoutputstream;1
@mozilla.org/byte-buffer;1
@mozilla.org/io/multiplex-input-stream;1
@mozilla.org/io/string-input-stream;1
@mozilla.org/network/buffered-input-stream;1
@mozilla.org/network/buffered-output-stream;1
@mozilla.org/scriptableinputstream;1

Reference documentation is generated from Mozilla's source.

Add a note User Contributed Notes
No comments available

Copyright © 1999 - 2005 XULPlanet.com