Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsIFileStream.cpp File Reference
#include "nsIFileStream.h"
#include "nsFileSpec.h"
#include "nsCOMPtr.h"
#include "prerror.h"
#include "nsSegmentedBuffer.h"
#include "nsInt64.h"
#include "prio.h"

Go to the source code of this file.

Classes

class  FileImpl

Functions

static NS_METHOD nsWriteSegmentToFile (nsIInputStream *in, void *closure, const char *fromRawSegment, PRUint32 toOffset, PRUint32 count, PRUint32 *writeCount)
nsresult NS_NewTypicalInputFileStream (nsISupports **aResult, const nsFileSpec &inFile)
nsresult NS_NewTypicalOutputFileStream (nsISupports **aResult, const nsFileSpec &inFile)
NS_COM_OBSOLETE nsresult NS_NewIOFileStream (nsISupports **aResult, const nsFileSpec &inFile, PRInt32 nsprMode, PRInt32 accessMode)

Function Documentation

NS_COM_OBSOLETE nsresult NS_NewIOFileStream ( nsISupports **  aResult,
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 **  aResult,
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 **  aResult,
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:

static NS_METHOD nsWriteSegmentToFile ( nsIInputStream in,
void closure,
const char *  fromRawSegment,
PRUint32  toOffset,
PRUint32  count,
PRUint32 writeCount 
) [static]

Definition at line 464 of file nsIFileStream.cpp.

{
    NS_NOTREACHED("nsWriteSegmentToFile");
    return NS_ERROR_NOT_IMPLEMENTED;
}

Here is the caller graph for this function: