Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes
nsFileOutputStream Class Reference

#include <nsFileStreams.h>

Inheritance diagram for nsFileOutputStream:
Inheritance graph
[legend]
Collaboration diagram for nsFileOutputStream:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIOUTPUTSTREAM
NS_DECL_NSIFILEOUTPUTSTREAM 
nsFileOutputStream ()
virtual ~nsFileOutputStream ()
nsresult Close ()
nsresult InitWithFileDescriptor (PRFileDesc *fd, nsISupports *parent)
void seek (in long whence, in long long offset)
 seek
long long tell ()
 tell
void setEOF ()
 setEOF
void init (in nsIFile file, in long ioFlags, in long perm, in long behaviorFlags)
void close ()
 Close the stream.
void flush ()
 Flush the stream.
unsigned long write (in string aBuf, in unsigned long aCount)
 Write data into the stream.
unsigned long writeFrom (in nsIInputStream aFromStream, in unsigned long aCount)
 Writes data into the stream from an input stream.
unsigned long writeSegments (in nsReadSegmentFun aReader, in voidPtr aClosure, in unsigned long aCount)
 Low-level write method that has access to the stream's underlying buffer.
boolean isNonBlocking ()

Static Public Member Functions

static NS_METHOD Create (nsISupports *aOuter, REFNSIID aIID, void **aResult)

Public Attributes

const PRInt32 NS_SEEK_SET = 0
const PRInt32 NS_SEEK_CUR = 1
const PRInt32 NS_SEEK_END = 2

Protected Attributes

PRFileDescmFD
nsCOMPtr< nsISupports > mParent
PRBool mCloseFD

Detailed Description

Definition at line 140 of file nsFileStreams.h.


Constructor & Destructor Documentation

NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIOUTPUTSTREAM NS_DECL_NSIFILEOUTPUTSTREAM nsFileOutputStream::nsFileOutputStream ( ) [inline]

Definition at line 148 of file nsFileStreams.h.

: nsFileStream() {}
virtual nsFileOutputStream::~nsFileOutputStream ( ) [inline, virtual]

Definition at line 149 of file nsFileStreams.h.

Here is the call graph for this function:


Member Function Documentation

nsresult nsFileStream::Close ( void  ) [inherited]

Reimplemented in nsSafeFileOutputStream.

Definition at line 121 of file nsFileStreams.cpp.

{
    nsresult rv = NS_OK;
    if (mFD) {
        if (mCloseFD)
            if (PR_Close(mFD) == PR_FAILURE)
                rv = NS_BASE_STREAM_OSERROR;
        mFD = nsnull;
    }
    return rv;
}

Here is the caller graph for this function:

void nsIOutputStream::close ( ) [inherited]

Close the stream.

Forces the output stream to flush any buffered data.

Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif unable to flush without blocking the calling thread (non-blocking mode only)
static NS_METHOD nsFileOutputStream::Create ( nsISupports *  aOuter,
REFNSIID  aIID,
void **  aResult 
) [static]
void nsIOutputStream::flush ( ) [inherited]

Flush the stream.

Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif unable to flush without blocking the calling thread (non-blocking mode only)
void nsIFileOutputStream::init ( in nsIFile  file,
in long  ioFlags,
in long  perm,
in long  behaviorFlags 
) [inherited]
Parameters:
file- file to write to (must QI to nsILocalFile)
ioFlags- file open flags listed in prio.h
perm- file mode bits listed in prio.h
behaviorFlagsflags specifying various behaviors of the class (currently none supported)
nsresult nsFileStream::InitWithFileDescriptor ( PRFileDesc fd,
nsISupports *  parent 
) [inherited]

Definition at line 106 of file nsFileStreams.cpp.

{
    NS_ENSURE_TRUE(mFD == nsnull, NS_ERROR_ALREADY_INITIALIZED);
    //
    // this file stream is dependent on its parent to keep the
    // file descriptor valid.  an owning reference to the parent
    // prevents the file descriptor from going away prematurely.
    //
    mFD = fd;
    mCloseFD = PR_FALSE;
    mParent = parent;
    return NS_OK;
}
Returns:
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.

void nsISeekableStream::seek ( in long  whence,
in long long  offset 
) [inherited]

seek

This method moves the stream offset of the steam implementing this interface.

Parameters:
whencespecifies how to interpret the 'offset' parameter in setting the stream offset associated with the implementing stream.
offsetspecifies a value, in bytes, that is used in conjunction with the 'whence' parameter to set the stream offset of the implementing stream. A negative value causes seeking in the reverse direction.

setEOF

This method truncates the stream at the current offset.

tell

This method reports the current offset, in bytes, from the start of the stream.

unsigned long nsIOutputStream::write ( in string  aBuf,
in unsigned long  aCount 
) [inherited]

Write data into the stream.

Parameters:
aBufthe buffer containing the data to be written
aCountthe maximum number of bytes to be written
Returns:
number of bytes written (may be less than aCount)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif writing to the output stream would block the calling thread (non-blocking mode only)
<other-error>on failure
unsigned long nsIOutputStream::writeFrom ( in nsIInputStream  aFromStream,
in unsigned long  aCount 
) [inherited]

Writes data into the stream from an input stream.

Parameters:
aFromStreamthe stream containing the data to be written
aCountthe maximum number of bytes to be written
Returns:
number of bytes written (may be less than aCount)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif writing to the output stream would block the calling thread (non-blocking mode only)
<other-error>on failure

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.

unsigned long nsIOutputStream::writeSegments ( in nsReadSegmentFun  aReader,
in voidPtr  aClosure,
in unsigned long  aCount 
) [inherited]

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.

Parameters:
aReaderthe "provider" of the data to be written
aClosureopaque parameter passed to reader
aCountthe maximum number of bytes to be written
Returns:
number of bytes written (may be less than aCount)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif writing to the output stream would block the calling thread (non-blocking mode only)
<other-error>on failure

NOTE: this function may be unimplemented if a stream has no underlying buffer (e.g., socket output stream).


Member Data Documentation

PRBool nsFileStream::mCloseFD [protected, inherited]

Definition at line 72 of file nsFileStreams.h.

PRFileDesc* nsFileStream::mFD [protected, inherited]

Definition at line 69 of file nsFileStreams.h.

nsCOMPtr<nsISupports> nsFileStream::mParent [protected, inherited]

Definition at line 70 of file nsFileStreams.h.

Definition at line 62 of file nsISeekableStream.idl.

Definition at line 68 of file nsISeekableStream.idl.

Definition at line 56 of file nsISeekableStream.idl.


The documentation for this class was generated from the following file: