Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
nsFileStreams.cpp File Reference
#include "private/pprio.h"
#include "nsFileStreams.h"
#include "nsILocalFile.h"
#include "nsXPIDLString.h"
#include "prerror.h"
#include "nsCRT.h"
#include "nsInt64.h"
#include "nsIFile.h"
#include "nsDirectoryIndexStream.h"
#include "nsMimeTypes.h"
#include "nsReadLine.h"
#include "nsNetUtil.h"

Go to the source code of this file.

Defines

#define NS_NO_INPUT_BUFFERING   1

Functions

 NS_IMPL_ISUPPORTS_INHERITED3 (nsFileInputStream, nsFileStream, nsIInputStream, nsIFileInputStream, nsILineInputStream) NS_METHOD nsFileInputStream
 NS_IMPL_ISUPPORTS_INHERITED2 (nsFileOutputStream, nsFileStream, nsIOutputStream, nsIFileOutputStream) NS_METHOD nsFileOutputStream
 NS_IMPL_ISUPPORTS_INHERITED3 (nsSafeFileOutputStream, nsFileOutputStream, nsISafeOutputStream, nsIOutputStream, nsIFileOutputStream) NS_IMETHODIMP nsSafeFileOutputStream

Define Documentation

Definition at line 70 of file nsFileStreams.cpp.


Function Documentation

Definition at line 387 of file nsFileStreams.cpp.

{
    NS_ENSURE_NO_AGGREGATION(aOuter);

    nsFileOutputStream* stream = new nsFileOutputStream();
    if (stream == nsnull)
        return NS_ERROR_OUT_OF_MEMORY;
    NS_ADDREF(stream);
    nsresult rv = stream->QueryInterface(aIID, aResult);
    NS_RELEASE(stream);
    return rv;
}

Here is the call graph for this function:

Definition at line 203 of file nsFileStreams.cpp.

{
    NS_ENSURE_NO_AGGREGATION(aOuter);

    nsFileInputStream* stream = new nsFileInputStream();
    if (stream == nsnull)
        return NS_ERROR_OUT_OF_MEMORY;
    NS_ADDREF(stream);
    nsresult rv = stream->QueryInterface(aIID, aResult);
    NS_RELEASE(stream);
    return rv;
}

Here is the call graph for this function:

Definition at line 491 of file nsFileStreams.cpp.

{
    NS_ENSURE_ARG(file);

    nsresult rv = file->Exists(&mTargetFileExists);
    if (NS_FAILED(rv)) {
        NS_ERROR("Can't tell if target file exists");
        mTargetFileExists = PR_TRUE; // Safer to assume it exists - we just do more work.
    }

    // follow symlinks, for two reasons:
    // 1) if a user has deliberately set up a profile file as a symlink, we honor it
    // 2) to make the MoveToNative() in Finish() an atomic operation (which may not
    //    be the case if moving across directories on different filesystems).
    nsCOMPtr<nsIFile> tempResult;
    rv = file->Clone(getter_AddRefs(tempResult));
    if (NS_SUCCEEDED(rv)) {
        nsCOMPtr<nsILocalFile> tempLocal = do_QueryInterface(tempResult);
        if (tempLocal)
            tempLocal->SetFollowLinks(PR_TRUE);

        // XP_UNIX ignores SetFollowLinks(), so we have to normalize.
        tempResult->Normalize();
    }

    if (NS_SUCCEEDED(rv) && mTargetFileExists) {
        PRUint32 origPerm;
        if (NS_FAILED(file->GetPermissions(&origPerm))) {
            NS_ERROR("Can't get permissions of target file");
            origPerm = perm;
        }
        // XXX What if |perm| is more restrictive then |origPerm|?
        // This leaves the user supplied permissions as they were.
        rv = tempResult->CreateUnique(nsIFile::NORMAL_FILE_TYPE, origPerm);
    }
    if (NS_SUCCEEDED(rv)) {
        mTempFile = tempResult;
        mTargetFile = file;
        rv = nsFileOutputStream::Init(mTempFile, ioFlags, perm, behaviorFlags);
    }
    return rv;
}

Here is the call graph for this function: