Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions
nsIFileStream.h File Reference
#include "xpcomobsolete.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsISeekableStream.h"
#include "prio.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  nsIOpenFile
class  nsIRandomAccessStore
class  nsIFileSpecInputStream
class  nsIFileSpecOutputStream

Defines

#define NS_IOPENFILE_IID
#define NS_IRANDOMACCESS_IID
#define NS_IFILESPECINPUTSTREAM_IID
#define NS_IFILESPECOUTPUTSTREAM_IID

Functions

nsresult NS_NewTypicalInputFileStream (nsISupports **aStreamResult, const nsFileSpec &inFile)
nsresult NS_NewTypicalOutputFileStream (nsISupports **aStreamResult, const nsFileSpec &inFile)
NS_COM_OBSOLETE nsresult NS_NewIOFileStream (nsISupports **aStreamResult, const nsFileSpec &inFile, PRInt32 nsprMode, PRInt32 accessMode)

Define Documentation

Value:
{ 0xa6cf90e6, 0x15b3, 0x11d2, \
    {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }

Definition at line 97 of file nsIFileStream.h.

Value:
{ 0xa6cf90e7, 0x15b3, 0x11d2, \
    {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }

Definition at line 114 of file nsIFileStream.h.

Value:
{ 0xa6cf90e8, 0x15b3, 0x11d2, \
    {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }

Definition at line 49 of file nsIFileStream.h.

Value:
{  0xa6cf90eb, 0x15b3, 0x11d2, \
    {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }

Definition at line 74 of file nsIFileStream.h.


Function Documentation

NS_COM_OBSOLETE nsresult NS_NewIOFileStream ( nsISupports **  aStreamResult,
const nsFileSpec inFile,
PRInt32  nsprMode,
PRInt32  accessMode 
)

Definition at line 698 of file nsIFileStream.cpp.

{
    NS_PRECONDITION(aResult != nsnull, "null ptr");
    if (!aResult)
        return NS_ERROR_NULL_POINTER;

    FileImpl* stream = new FileImpl(inFile, nsprMode, accessMode);
    if (! stream)
        return NS_ERROR_OUT_OF_MEMORY;

    NS_ADDREF(stream);
    PRBool isOpened = PR_FALSE;
    stream->GetIsOpen(&isOpened);
    if (!isOpened)
    {
        NS_RELEASE(stream);
        return NS_ERROR_FAILURE;
    }

    *aResult = (nsISupports*)(void*)stream;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewTypicalInputFileStream ( nsISupports **  aStreamResult,
const nsFileSpec inFile 
)

Definition at line 612 of file nsIFileStream.cpp.

{
  // This QueryInterface was needed because NS_NewIOFileStream
  // does a cast from (void *) to (nsISupports *) thus causing a 
  // vtable problem on Windows, where we really didn't have the proper pointer
  // to an nsIInputStream, this ensures that we do 
    nsISupports    * supports;
    nsIInputStream * inStr;

    nsresult rv = NS_NewIOFileStream(&supports, inFile, PR_RDONLY, 0666);

    *aResult = nsnull;
    if (NS_SUCCEEDED(rv)) {
      if (NS_SUCCEEDED(supports->QueryInterface(NS_GET_IID(nsIInputStream), (void**)&inStr))) {
        *aResult = inStr;
      }
      NS_RELEASE(supports);
    }
    return rv;
}

Here is the call graph for this function:

nsresult NS_NewTypicalOutputFileStream ( nsISupports **  aStreamResult,
const nsFileSpec inFile 
)

Definition at line 640 of file nsIFileStream.cpp.

{
  // This QueryInterface was needed because NS_NewIOFileStream
  // does a cast from (void *) to (nsISupports *) thus causing a 
  // vtable problem on Windows, where we really didn't have the proper pointer
  // to an nsIOutputStream, this ensures that we do 
#if 1
/*    nsISupports     * supports;
    nsIOutputStream * outStr;

    nsresult rv = NS_NewIOFileStream(
        &supports,
        inFile,
        (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE),
        0666);

    *aResult = nsnull;
    if (NS_SUCCEEDED(rv)) { 
      if (NS_SUCCEEDED(supports->QueryInterface(NS_GET_IID(nsIOutputStream), (void**)&outStr))) {
        *aResult = outStr;
      }
      NS_RELEASE(supports);
    }
    return rv;
    */

    nsCOMPtr<nsISupports> supports;
    nsIOutputStream * outStr;

    nsresult rv = NS_NewIOFileStream(
        getter_AddRefs(supports),
        inFile,
        (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE),
        0666);

    *aResult = nsnull;
    if (NS_SUCCEEDED(rv)) { 
      if (NS_SUCCEEDED(supports->QueryInterface(NS_GET_IID(nsIOutputStream), (void**)&outStr))) {
        *aResult = outStr;
      }
    }
    return rv;
#else
    return NS_NewIOFileStream(
        aResult,
        inFile,
        (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE),
        0666);
#endif
}

Here is the call graph for this function: