nsIFileOutputStream

This interface is an output stream that lets you stream to a file.
Inherits from: nsIOutputStream Last changed in Gecko 1.7

Method overview

void init(in nsIFile file, in long ioFlags, in long perm, in long behaviorFlags);

Constants

Behavior flag constants

Constant Value Description
DEFER_OPEN 1<<0 See the same constant in nsIFileInputStream. The deferred open will be performed when one of the following is called:
  • Seek()
  • Tell()
  • Write()
  • Flush()

DEFER_OPEN is useful if we use the stream on a background thread, so that the opening and possible stating of the file happens there as well.

Note: Using this flag results in the file not being opened during the call to init(). This means that any errors that might happen when this flag is not set would happen during the first write, and if the file is to be created, it will not appear on the disk until the first write.

Methods

init()

void init(
  in nsIFile file,
  in long ioFlags,
  in long perm,
  in long behaviorFlags
);
Parameters
file
File to write to (must QI to nsILocalFile)
ioFlags
File open flags listed are listed in the PR_Open() documentation. Use -1 to open the file in default mode (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE).
perm
File mode bits are described in the PR_Open documentation. If set to -1 the default permissions (0664) will be used.
behaviorFlags
Flags specifying various behaviors of the class; see Behavior flag constants above.

See also