Back to index

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

#include <nsImportScanFile.h>

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

List of all members.

Public Member Functions

 nsImportScanFile ()
 nsImportScanFile (nsIFileSpec *pSpec, PRUint8 *pBuf, PRUint32 sz)
virtual ~nsImportScanFile ()
void InitScan (nsIFileSpec *pSpec, PRUint8 *pBuf, PRUint32 sz)
PRBool OpenScan (nsIFileSpec *pSpec, PRUint32 bufSz=4096)
void CleanUpScan (void)
virtual PRBool Scan (PRBool *pDone)

Protected Member Functions

void ShiftBuffer (void)
PRBool FillBufferFromFile (void)
virtual PRBool ScanBuffer (PRBool *pDone)

Protected Attributes

nsIFileSpecm_pFile
PRUint8m_pBuf
PRUint32 m_bufSz
PRUint32 m_bytesInBuf
PRUint32 m_pos
PRBool m_eof
PRBool m_allocated

Detailed Description

Definition at line 43 of file nsImportScanFile.h.


Constructor & Destructor Documentation

Definition at line 44 of file nsImportScanFile.cpp.

Definition at line 52 of file nsImportScanFile.cpp.

{
       m_allocated = PR_FALSE;
       m_eof = PR_FALSE;
       InitScan( pSpec, pBuf, sz);
}

Here is the call graph for this function:

Definition at line 59 of file nsImportScanFile.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 106 of file nsImportScanFile.cpp.

{
       NS_IF_RELEASE( m_pFile);
       m_pFile = nsnull;
       if (m_allocated) {
              if (m_pBuf)
                     delete [] m_pBuf;
              m_pBuf = NULL;
       }
}

Here is the caller graph for this function:

Definition at line 137 of file nsImportScanFile.cpp.

{
       PRBool eof = PR_FALSE;
       nsresult rv = m_pFile->Eof( &eof);
       if (eof) {
              return( PR_FALSE);
       }

       // Fill up a buffer and scan it
       ShiftBuffer();

       // Read in some more bytes
       PRUint32      cnt = m_bufSz - m_bytesInBuf;
       // To distinguish from disk errors
       // Check first for end of file?
       // Set a done flag if true...
       PRInt32 read;
       char *pBuf = (char *)m_pBuf;
       pBuf += m_bytesInBuf;
       rv = m_pFile->Read( &pBuf, (PRInt32) cnt, &read);

       if (NS_FAILED( rv))
              return( PR_FALSE);
       eof = PR_FALSE;
       rv = m_pFile->Eof( &eof);
       if (eof)
              m_eof = PR_TRUE;

       m_bytesInBuf += cnt;
       return( PR_TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImportScanFile::InitScan ( nsIFileSpec pSpec,
PRUint8 pBuf,
PRUint32  sz 
)

Definition at line 96 of file nsImportScanFile.cpp.

{
       m_pFile = pSpec;
       NS_IF_ADDREF( pSpec);
       m_pBuf = pBuf;
       m_bufSz = sz;
       m_bytesInBuf = 0;
       m_pos = 0;
}

Here is the caller graph for this function:

PRBool nsImportScanFile::OpenScan ( nsIFileSpec pSpec,
PRUint32  bufSz = 4096 
)

Definition at line 68 of file nsImportScanFile.cpp.

{
       if (!bufSz)
              bufSz = 32 * 1024;
       if (!m_pBuf) {
              m_pBuf = new PRUint8[bufSz];
       }
       
       PRBool open = PR_FALSE;
       nsresult rv = pSpec->IsStreamOpen( &open);
       if (NS_FAILED( rv) || !open) {
              rv = pSpec->OpenStreamForReading();
              if (NS_FAILED( rv)) {
                     delete [] m_pBuf;
                     m_pBuf = nsnull;
                     return( PR_FALSE);
              }
       }
       m_pFile = pSpec;
       NS_IF_ADDREF( m_pFile);
       m_allocated = PR_TRUE;
       m_bytesInBuf = 0;
       m_pos = 0;
       m_bufSz = bufSz;
       return( PR_TRUE);
}
PRBool nsImportScanFile::Scan ( PRBool pDone) [virtual]

Reimplemented in nsImportEncodeScan.

Definition at line 169 of file nsImportScanFile.cpp.

{
       PRBool eof = PR_FALSE;
       m_pFile->Eof( &eof);

       if (eof) {
              if (m_pos < m_bytesInBuf) {
                     ScanBuffer( pDone);
              }
              *pDone = PR_TRUE;
              return( PR_TRUE);
       }

       // Fill up a buffer and scan it
       if (!FillBufferFromFile())
              return( PR_FALSE);

       return( ScanBuffer( pDone));
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsImportScanFile::ScanBuffer ( PRBool pDone) [protected, virtual]

Reimplemented in nsImportScanFileLines, and nsImportMimeEncode.

Definition at line 189 of file nsImportScanFile.cpp.

{
       return( PR_TRUE);
}

Here is the caller graph for this function:

Definition at line 117 of file nsImportScanFile.cpp.

{
       PRUint8 *     pTop;
       PRUint8 *     pCurrent;

       if (m_pos < m_bytesInBuf) {
              pTop = m_pBuf;
              pCurrent = pTop + m_pos;
              PRUint32             cnt = m_bytesInBuf - m_pos;
              while (cnt) {
                     *pTop = *pCurrent;
                     pTop++; pCurrent++;
                     cnt--;
              }
       }

       m_bytesInBuf -= m_pos;
       m_pos = 0;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 68 of file nsImportScanFile.h.

Definition at line 64 of file nsImportScanFile.h.

Definition at line 65 of file nsImportScanFile.h.

Definition at line 67 of file nsImportScanFile.h.

Definition at line 63 of file nsImportScanFile.h.

Definition at line 62 of file nsImportScanFile.h.

Definition at line 66 of file nsImportScanFile.h.


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