Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Attributes
FileSpecWorker Class Reference
Inheritance diagram for FileSpecWorker:
Inheritance graph
[legend]
Collaboration diagram for FileSpecWorker:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_IMETHOD Run ()
 Defines an entry point for a newly created thread.
NS_DECL_ISUPPORTS FileSpecWorker ()
nsresult Init (nsIFile *inPath, nsIFile *outPath, PRUint32 bufferSize)
virtual ~FileSpecWorker ()
void run ()

Static Public Member Functions

static nsresult Create (nsIRunnable **result, nsIFile *inPath, nsIFile *outPath, PRUint32 bufferSize)

Protected Attributes

nsCOMPtr< nsIFilemInPath
nsCOMPtr< nsIFilemOutPath
char * mBuffer
PRUint32 mBufferSize

Detailed Description

Definition at line 163 of file TestFileInput2.cpp.


Constructor & Destructor Documentation

Definition at line 206 of file TestFileInput2.cpp.

Here is the caller graph for this function:

virtual FileSpecWorker::~FileSpecWorker ( ) [inline, virtual]

Definition at line 242 of file TestFileInput2.cpp.

                              {
        delete[] mBuffer;
    }

Member Function Documentation

static nsresult FileSpecWorker::Create ( nsIRunnable **  result,
nsIFile inPath,
nsIFile outPath,
PRUint32  bufferSize 
) [inline, static]

Definition at line 223 of file TestFileInput2.cpp.

    {
        FileSpecWorker* worker = new FileSpecWorker();
        if (worker == nsnull)
            return NS_ERROR_OUT_OF_MEMORY;
        NS_ADDREF(worker);

        nsresult rv = worker->Init(inPath, outPath, bufferSize);
        if (NS_FAILED(rv)) {
            NS_RELEASE(worker);
            return rv;
        }
        *result = worker;
        return NS_OK;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult FileSpecWorker::Init ( nsIFile inPath,
nsIFile outPath,
PRUint32  bufferSize 
) [inline]

Definition at line 212 of file TestFileInput2.cpp.

    {
        mInPath = inPath;
        mOutPath = outPath;
        mBuffer = new char[bufferSize];
        mBufferSize = bufferSize;
        return (mInPath && mOutPath && mBuffer)
            ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
    }

Here is the caller graph for this function:

void nsIRunnable::run ( ) [inherited]
NS_IMETHOD FileSpecWorker::Run ( ) [inline, virtual]

Defines an entry point for a newly created thread.

Implements nsIRunnable.

Definition at line 166 of file TestFileInput2.cpp.

                     {
        nsresult rv;

        PRIntervalTime startTime = PR_IntervalNow();
        PRIntervalTime endTime;
        nsCOMPtr<nsIInputStream> inStr;
        nsCOMPtr<nsIOutputStream> outStr;
        PRUint32 copyCount = 0;

        // Open the input stream:
        nsCOMPtr<nsIInputStream> fileIn;
        rv = NS_NewLocalFileInputStream(getter_AddRefs(fileIn), mInPath);
        if (NS_FAILED(rv)) return rv;

        rv = NS_NewBufferedInputStream(getter_AddRefs(inStr), fileIn, 65535);
        if (NS_FAILED(rv)) return rv;

        // Open the output stream:
        nsCOMPtr<nsIOutputStream> fileOut;
        rv = NS_NewLocalFileOutputStream(getter_AddRefs(fileOut),
                                         mOutPath, 
                                         PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE,
                                         0664);
        if (NS_FAILED(rv)) return rv;

        rv = NS_NewBufferedOutputStream(getter_AddRefs(outStr), fileOut, 65535);
        if (NS_FAILED(rv)) return rv;

        // Copy from one to the other
        rv = Copy(inStr, outStr, mBuffer, mBufferSize, &copyCount);
        if (NS_FAILED(rv)) return rv;

        endTime = PR_IntervalNow();
        gTimeSampler.AddTime(endTime - startTime);

        return rv;
    }

Here is the call graph for this function:


Member Data Documentation

char* FileSpecWorker::mBuffer [protected]

Definition at line 249 of file TestFileInput2.cpp.

Definition at line 250 of file TestFileInput2.cpp.

Definition at line 247 of file TestFileInput2.cpp.

Definition at line 248 of file TestFileInput2.cpp.


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