Back to index

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

#include <nsImportMimeEncode.h>

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

List of all members.

Public Member Functions

 nsImportMimeEncode ()
 ~nsImportMimeEncode ()
void EncodeFile (nsIFileSpec *pInFile, ImportOutFile *pOut, const char *pFileName, const char *pMimeType)
PRBool DoWork (PRBool *pDone)
long NumBytesProcessed (void)
PRBool InitEncodeScan (PRBool appleSingleEncode, nsIFileSpec *pSpec, const char *pName, PRUint8 *pBuf, PRUint32 sz)
void CleanUpEncodeScan (void)
virtual PRBool Scan (PRBool *pDone)
void InitScan (nsIFileSpec *pSpec, PRUint8 *pBuf, PRUint32 sz)
PRBool OpenScan (nsIFileSpec *pSpec, PRUint32 bufSz=4096)
void CleanUpScan (void)

Protected Member Functions

void CleanUp (void)
PRBool SetUpEncode (void)
PRBool WriteFileName (nsCString &fName, PRBool wasTrans, const char *pTag)
PRBool TranslateFileName (nsCString &inFile, nsCString &outFile)
virtual PRBool ScanBuffer (PRBool *pDone)
void FillInEntries (int numEntries)
PRBool AddEntries (void)
void ShiftBuffer (void)
PRBool FillBufferFromFile (void)

Protected Attributes

nsCString m_fileName
nsIFileSpecm_pMimeFile
ImportOutFilem_pOut
nsCString m_mimeType
int m_state
long m_bytesProcessed
PRUint8m_pInputBuf
PRBool m_appleSingle
int m_lineLen
PRBool m_isAppleSingle
nsIFileSpecm_pInputFile
int m_encodeScanState
long m_resourceForkSize
long m_dataForkSize
nsCString m_useFileName
nsIFileSpecm_pFile
PRUint8m_pBuf
PRUint32 m_bufSz
PRUint32 m_bytesInBuf
PRUint32 m_pos
PRBool m_eof
PRBool m_allocated

Detailed Description

Definition at line 51 of file nsImportMimeEncode.h.


Constructor & Destructor Documentation

Definition at line 63 of file nsImportMimeEncode.cpp.


Member Function Documentation

PRBool nsImportEncodeScan::AddEntries ( void  ) [protected, inherited]

Definition at line 219 of file nsImportEncodeScan.cpp.

{
#ifdef _MAC_IMPORT_CODE
       if (!g2000Secs) {
              g2000Secs = Get2000Secs();
              gGMTDelta = GetGmtDelta();
       }
       MemCpy( m_pBuf + m_bytesInBuf, (PC_S8) m_useFileName, m_useFileName.GetLength());
       m_bytesInBuf += m_useFileName.GetLength();              
       if (m_useFileName.GetLength() < 32) {
              int len = m_useFileName.GetLength();
              while (len < 32) {
                     *((P_S8)m_pBuf + m_bytesInBuf) = 0;
                     m_bytesInBuf++;
                     len++;
              }
       }
       
       Str255 comment;
       comment[0] = 0;
       OSErr err = FSpDTGetComment( m_inputFileLoc, comment);
       comment[0] = 200;
       MemCpy( m_pBuf + m_bytesInBuf, &(comment[1]), comment[0]);
       m_bytesInBuf += comment[0];
       
       long   dates[4];
       dates[0] = gCatInfoPB.hFileInfo.ioFlCrDat;
       dates[1] = gCatInfoPB.hFileInfo.ioFlMdDat;
       dates[2] = gCatInfoPB.hFileInfo.ioFlBkDat;
       dates[3] = 0x80000000;
       for (short i = 0; i < 3; i++) {
              dates[i] -= g2000Secs;
              dates[i] += gGMTDelta;
       }
       MemCpy( m_pBuf + m_bytesInBuf, dates, 16);
       m_bytesInBuf += 16;
       
       
       FInfo  fInfo = gCatInfoPB.hFileInfo.ioFlFndrInfo;
       FXInfo fxInfo = gCatInfoPB.hFileInfo.ioFlXFndrInfo;
       fInfo.fdFlags = 0;
       fInfo.fdLocation.h = 0;
       fInfo.fdLocation.v = 0;
       fInfo.fdFldr = 0;
       MemSet( &fxInfo, 0, sizeof( fxInfo));
       MemCpy( m_pBuf + m_bytesInBuf, &fInfo, 16);
       m_bytesInBuf += 16;
       MemCpy( m_pBuf + m_bytesInBuf, &fxInfo, 16);
       m_bytesInBuf += 16;
       
       
       dates[0] = 0;
       if ((gCatInfoPB.hFileInfo.ioFlAttrib & 1) != 0)
              dates[0] |= 1;
       MemCpy( m_pBuf + m_bytesInBuf, dates, 4);
       m_bytesInBuf += 4;
       
       
#endif
       return( PR_TRUE);
}

Here is the caller graph for this function:

Definition at line 82 of file nsImportMimeEncode.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 138 of file nsImportEncodeScan.cpp.

Here is the caller graph for this function:

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 167 of file nsImportMimeEncode.cpp.

{      
       *pDone = PR_FALSE;
       switch( m_state) {
       case kNoState:
              return( PR_FALSE);
              break;
       case kStartState:
              return( SetUpEncode());
              break;
       case kEncodeState:
              if (!Scan( pDone)) {
                     CleanUp();
                     return( PR_FALSE);
              }
              if (*pDone) {
                     *pDone = PR_FALSE;
                     m_state = kDoneState;
              }
              break;
       case kDoneState:
              CleanUp();
              m_state = kNoState;
              *pDone = PR_TRUE;
              break;
       }

       return( PR_TRUE);
}

Here is the call graph for this function:

void nsImportMimeEncode::EncodeFile ( nsIFileSpec pInFile,
ImportOutFile pOut,
const char *  pFileName,
const char *  pMimeType 
)

Definition at line 70 of file nsImportMimeEncode.cpp.

{
       m_fileName = pFileName;
       m_mimeType = pMimeType;

       m_pMimeFile = pInFile;
       NS_IF_ADDREF( m_pMimeFile);

       m_pOut = pOut;
       m_state = kStartState;
}
PRBool nsImportScanFile::FillBufferFromFile ( void  ) [protected, inherited]

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 nsImportEncodeScan::FillInEntries ( int  numEntries) [protected, inherited]

Definition at line 147 of file nsImportEncodeScan.cpp.

{
#ifdef _MAC_IMPORT_CODE
       int           len = m_useFileName.GetLength();
       if (len < 32)
              len = 32;
       long   entry[3];
       long   fileOffset = 26 + (12 * numEntries);
       entry[0] = 3;
       entry[1] = fileOffset;
       entry[2] = m_useFileName.GetLength();
       fileOffset += len;
       MemCpy( m_pBuf + m_bytesInBuf, entry, 12);
       m_bytesInBuf += 12;         
       
       
       Str255 comment;
       comment[0] = 0;
       OSErr err = FSpDTGetComment( m_inputFileLoc, comment);
       if (comment[0] > 200)
              comment[0] = 200;
       entry[0] = 4;
       entry[1] = fileOffset;
       entry[2] = comment[0];
       fileOffset += 200;
       MemCpy( m_pBuf + m_bytesInBuf, entry, 12);
       m_bytesInBuf += 12;         
       
       
       entry[0] = 8;
       entry[1] = fileOffset;
       entry[2] = 16;
       fileOffset += 16;
       MemCpy( m_pBuf + m_bytesInBuf, entry, 12);
       m_bytesInBuf += 12;         
       
       entry[0] = 9;
       entry[1] = fileOffset;
       entry[2] = 32;
       fileOffset += 32;
       MemCpy( m_pBuf + m_bytesInBuf, entry, 12);
       m_bytesInBuf += 12;         

       
       entry[0] = 10;
       entry[1] = fileOffset;
       entry[2] = 4;
       fileOffset += 4;
       MemCpy( m_pBuf + m_bytesInBuf, entry, 12);
       m_bytesInBuf += 12;
       
       if (m_resourceForkSize) {
              entry[0] = 2;
              entry[1] = fileOffset;
              entry[2] = m_resourceForkSize;
              fileOffset += m_resourceForkSize;
              MemCpy( m_pBuf + m_bytesInBuf, entry, 12);
              m_bytesInBuf += 12;         
       }
       
       if (m_dataForkSize) {
              entry[0] = 1;
              entry[1] = fileOffset;
              entry[2] = m_dataForkSize;
              fileOffset += m_dataForkSize;
              MemCpy( m_pBuf + m_bytesInBuf, entry, 12);
              m_bytesInBuf += 12;
       }
       
#endif        
}

Here is the caller graph for this function:

PRBool nsImportEncodeScan::InitEncodeScan ( PRBool  appleSingleEncode,
nsIFileSpec pSpec,
const char *  pName,
PRUint8 pBuf,
PRUint32  sz 
) [inherited]

Definition at line 106 of file nsImportEncodeScan.cpp.

{
       CleanUpEncodeScan();
       m_isAppleSingle = appleSingleEncode;
       m_encodeScanState = kBeginAppleSingle;
       m_pInputFile = fileLoc;
       NS_IF_ADDREF( m_pInputFile);
       m_useFileName = pName;
       m_pBuf = pBuf;
       m_bufSz = sz;
       if (!m_isAppleSingle) {
              PRBool open = PR_FALSE;
              nsresult rv = m_pInputFile->IsStreamOpen( &open);
              if (NS_FAILED( rv) || !open) {
                     rv = m_pInputFile->OpenStreamForReading();
                     if (NS_FAILED( rv))
                            return( PR_FALSE);
              }

              InitScan( m_pInputFile, pBuf, sz);
       }
       else {
       #ifdef _MAC_IMPORT_CODE
              // Fill in the file sizes
              m_resourceForkSize = fileLoc.GetMacFileSize( UFileLocation::eResourceFork);
              m_dataForkSize = fileLoc.GetMacFileSize( UFileLocation::eDataFork);
       #endif
       }

       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 
) [inherited]

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:

Definition at line 60 of file nsImportMimeEncode.h.

{ long val = m_bytesProcessed; m_bytesProcessed = 0; return( val);}
PRBool nsImportScanFile::OpenScan ( nsIFileSpec pSpec,
PRUint32  bufSz = 4096 
) [inherited]

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 nsImportEncodeScan::Scan ( PRBool pDone) [virtual, inherited]

Reimplemented from nsImportScanFile.

Definition at line 281 of file nsImportEncodeScan.cpp.

{
       nsresult      rv;

       *pDone = PR_FALSE;
       if (m_isAppleSingle) {
              // Stuff the buffer with things needed to encode the file...
              // then just allow UScanFile to handle each fork, but be careful
              // when handling eof.
              switch( m_encodeScanState) {
                     case kBeginAppleSingle: {
                            #ifdef _MAC_IMPORT_CODE
                            OSErr err = GetCatInfoNoName( m_inputFileLoc.GetVRefNum(), m_inputFileLoc.GetParID(), m_inputFileLoc.GetFileNamePtr(), &gCatInfoPB);
                            if (err != noErr)
                                   return( FALSE);
                            #endif
                            m_eof = PR_FALSE;
                            m_pos = 0;
                            memcpy( m_pBuf, gAppleSingleHeader, kAppleSingleHeaderSize);
                            m_bytesInBuf = kAppleSingleHeaderSize;
                            int numEntries = 5;
                            if (m_dataForkSize)
                                   numEntries++;
                            if (m_resourceForkSize)
                                   numEntries++;
                            memcpy( m_pBuf + m_bytesInBuf, &numEntries, sizeof( numEntries));
                            m_bytesInBuf += sizeof( numEntries);
                            FillInEntries( numEntries);
                            m_encodeScanState = kAddEntries;
                            return( ScanBuffer( pDone));
                     }
                     break;
                     
                     case kBeginDataFork: {
                            if (!m_dataForkSize) {
                                   m_encodeScanState = kDoneWithFile;
                                   return( PR_TRUE);
                            }
                            // Initialize the scan of the data fork...
                            PRBool open = PR_FALSE;
                            rv = m_pInputFile->IsStreamOpen( &open);
                            if (!open)
                                   rv = m_pInputFile->OpenStreamForReading();
                            if (NS_FAILED( rv))
                                   return( PR_FALSE);   
                            m_encodeScanState = kScanningDataFork;
                            return( PR_TRUE);
                     }
                     break;
                     
                     case kScanningDataFork: {
                            PRBool result = FillBufferFromFile();
                            if (!result)
                                   return( PR_FALSE);
                            if (m_eof) {
                                   m_eof = PR_FALSE;
                                   result = ScanBuffer( pDone);
                                   if (!result)
                                          return( PR_FALSE);
                                   m_pInputFile->CloseStream();
                                   m_encodeScanState = kDoneWithFile;
                                   return( PR_TRUE);
                            }
                            else
                                   return( ScanBuffer( pDone));
                     }
                     break;
                     
                     case kScanningRsrcFork: {
                            PRBool result = FillBufferFromFile();
                            if (!result)
                                   return( PR_FALSE);
                            if (m_eof) {
                                   m_eof = PR_FALSE;
                                   result = ScanBuffer( pDone);
                                   if (!result)
                                          return( PR_FALSE);
                                   m_pInputFile->CloseStream();
                                   m_encodeScanState = kBeginDataFork;
                                   return( PR_TRUE);
                            }
                            else
                                   return( ScanBuffer( pDone));
                     }
                     break;
                     
                     case kBeginResourceFork: {
                            if (!m_resourceForkSize) {
                                   m_encodeScanState = kBeginDataFork;
                                   return( PR_TRUE);
                            }
                            /*
                            // FIXME: Open the resource fork on the Mac!!!
                            m_fH = UFile::OpenRsrcFileRead( m_inputFileLoc);
                            if (m_fH == TR_FILE_ERROR)
                                   return( FALSE);      
                            */
                            m_encodeScanState = kScanningRsrcFork;
                            return( PR_TRUE);
                     }
                     break;
                     
                     case kAddEntries: {
                            ShiftBuffer();
                            if (!AddEntries())
                                   return( PR_FALSE);
                            m_encodeScanState = kBeginResourceFork;
                            return( ScanBuffer( pDone));
                     }
                     break;
                     
                     case kDoneWithFile: {
                            ShiftBuffer();
                            m_eof = PR_TRUE;
                            if (!ScanBuffer( pDone))
                                   return( PR_FALSE);
                            *pDone = PR_TRUE;
                            return( PR_TRUE);
                     }
                     break;
              }
              
       }
       else
              return( nsImportScanFile::Scan( pDone));
              
       return( PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from nsImportScanFile.

Definition at line 199 of file nsImportMimeEncode.cpp.

{

       PRUint32      pos = m_pos;
       PRUint32      start = pos;
       PRUint8 *     pChar = m_pBuf + pos;
       PRUint32      max = m_bytesInBuf;
       PRUint8              byte[4];
       PRUint32      lineLen = m_lineLen;

       while ((pos + 2) < max) {
              // Encode 3 bytes
              byte[0] = gBase64[*pChar >> 2];
              byte[1] = gBase64[(((*pChar) & 0x3)<< 4) | (((*(pChar + 1)) & 0xF0) >> 4)];
              pChar++;
              byte[2] = gBase64[(((*pChar) & 0xF) << 2) | (((*(pChar + 1)) & 0xC0) >>6)];
              pChar++;
              byte[3] = gBase64[(*pChar) & 0x3F];
              if (!m_pOut->WriteData( byte, 4))
                     return( PR_FALSE);
              pos += 3;
              pChar++;
              lineLen += 4;
              if (lineLen > 71) {
                     if (!m_pOut->WriteEol())
                            return( PR_FALSE);
                     lineLen = 0;
              }
       }

       if ((pos < max) && m_eof) {
              // Get the last few bytes!
              byte[0] = gBase64[*pChar >> 2];
              pos++;
              if (pos < max) {
                     byte[1] = gBase64[(((*pChar) & 0x3)<< 4) | (((*(pChar + 1)) & 0xF0) >> 4)];
                     pChar++;
                     pos++;
                     if (pos < max) {
                            // Should be dead code!! (Then why is it here doofus?)
                            byte[2] = gBase64[(((*pChar) & 0xF) << 2) | (((*(pChar + 1)) & 0xC0) >>6)];
                            pChar++;
                            byte[3] = gBase64[(*pChar) & 0x3F];
                            pos++;
                     }
                     else {
                            byte[2] = gBase64[(((*pChar) & 0xF) << 2)];
                            byte[3] = '=';
                     }
              }
              else {
                     byte[1] = gBase64[(((*pChar) & 0x3)<< 4)];
                     byte[2] = '=';
                     byte[3] = '=';
              }
              
              if (!m_pOut->WriteData( byte, 4))
                     return( PR_FALSE);
              if (!m_pOut->WriteEol())
                     return( PR_FALSE);
       }
       else if (m_eof) {
              /*
              byte[0] = '=';
              if (!m_pOut->WriteData( byte, 1))
                     return( FALSE);
              */
              if (!m_pOut->WriteEol())
                     return( PR_FALSE);
       }
       
       m_lineLen = (int) lineLen;
       m_pos = pos;
       m_bytesProcessed += (pos - start);
       return( PR_TRUE);
}

Here is the call graph for this function:

Definition at line 87 of file nsImportMimeEncode.cpp.

{
       nsCString            errStr;
       if (!m_pInputBuf) {
              m_pInputBuf = new PRUint8[kEncodeBufferSz];
       }
       
       m_appleSingle = PR_FALSE;

#ifdef _MAC_IMPORT_CODE
       // First let's see just what kind of beast we have?
       // For files with only a data fork and a known mime type
       // proceed with normal mime encoding just as on the PC.
       // For unknown mime types and files with both forks,
       // encode as AppleSingle format.
       if (m_filePath.GetMacFileSize( UFileLocation::eResourceFork) || !pMimeType) {
              m_appleSingle = TRUE;
              m_mimeType = "application/applefile";
       }
#endif
       
       if (!InitEncodeScan( m_appleSingle, m_pMimeFile, m_fileName.get(), m_pInputBuf, kEncodeBufferSz)) {
              return( PR_FALSE);
       }
              
       m_state = kEncodeState;
       m_lineLen = 0;
       
       // Write out the boundary header
       PRBool bResult = PR_TRUE;
       bResult = m_pOut->WriteStr( "Content-type: ");
       if (bResult)
              bResult = m_pOut->WriteStr( m_mimeType.get());

#ifdef _MAC_IMPORT_CODE
       // include the type an creator here
       if (bResult)
              bResult = m_pOut->WriteStr( "; x-mac-type=\"");
       U8     hex[8];
       LongToHexBytes( m_filePath.GetFileType(), hex);
       if (bResult)
              bResult = m_pOut->WriteData( hex, 8);
       LongToHexBytes( m_filePath.GetFileCreator(), hex);
       if (bResult)
              bResult = m_pOut->WriteStr( "\"; x-mac-creator=\"");
       if (bResult)
              bResult = m_pOut->WriteData( hex, 8);
       if (bResult)
              bResult = m_pOut->WriteStr( "\"");
#endif

       /*
       if (bResult)
              bResult = m_pOut->WriteStr( gMimeTypeFileName);
       */
       if (bResult)
              bResult = m_pOut->WriteStr( ";\x0D\x0A");

       nsCString            fName;
       PRBool               trans = TranslateFileName( m_fileName, fName);
       if (bResult)
              bResult = WriteFileName( fName, trans, "name");
       if (bResult)
              bResult = m_pOut->WriteStr( "Content-transfer-encoding: base64");
       if (bResult)
              bResult = m_pOut->WriteEol();
       if (bResult)
              bResult = m_pOut->WriteStr( "Content-Disposition: attachment;\x0D\x0A");
       if (bResult)
              bResult = WriteFileName( fName, trans, "filename");
       if (bResult)
              bResult = m_pOut->WriteEol();

       if (!bResult) {
              CleanUp();
       }

       return( bResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImportScanFile::ShiftBuffer ( void  ) [protected, inherited]

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:

PRBool nsImportMimeEncode::TranslateFileName ( nsCString inFile,
nsCString outFile 
) [protected]

Definition at line 276 of file nsImportMimeEncode.cpp.

{
       const PRUint8 * pIn = (const PRUint8 *) inFile.get();
       int      len = inFile.Length();
       
       while (len) {
              if (!ImportCharSet::IsUSAscii( *pIn))
                     break;
              len--;
              pIn++;
       }
       if (len) {
              // non US ascii!
              // assume this string needs translating...
              if (!ImportTranslate::ConvertString( inFile, outFile, PR_TRUE)) {
                     outFile = inFile;
                     return( PR_FALSE);
              }
              else {
                     return( PR_TRUE);
              }
       }
       else {
              outFile = inFile;
              return( PR_FALSE);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsImportMimeEncode::WriteFileName ( nsCString fName,
PRBool  wasTrans,
const char *  pTag 
) [protected]

Definition at line 304 of file nsImportMimeEncode.cpp.

{
       int                  tagNum = 0;
       int                  idx = 0;
       PRBool        result = PR_TRUE;
       int                  len;
       nsCString     numStr;

       while ((((fName.Length() - idx) + strlen( pTag)) > 70) && result) {
              len = 68 - strlen( pTag) - 5;
              if (wasTrans) {
                     if (fName.CharAt( idx + len - 1) == '%')
                            len--;
                     else if (fName.CharAt( idx + len - 2) == '%')
                            len -= 2;
              }

              if (result)
                     result = m_pOut->WriteStr( "\x09");
              if (result)
                     result = m_pOut->WriteStr( pTag);
              numStr = "*";
              numStr.AppendInt( tagNum);
              if (result)
                     result = m_pOut->WriteStr( numStr.get());
              if (wasTrans && result)
                     result = m_pOut->WriteStr( "*=");
              else if (result)
                     result = m_pOut->WriteStr( "=\"");
              if (result)
                     result = m_pOut->WriteData( ((const PRUint8 *)fName.get()) + idx, len);
              if (wasTrans && result)
                     result = m_pOut->WriteStr( "\x0D\x0A");
              else if (result)
                     result = m_pOut->WriteStr( "\"\x0D\x0A");
              idx += len;
              tagNum++;
       }
       
       if (idx) {
              if ((fName.Length() - idx) > 0) {
                     if (result)
                            result = m_pOut->WriteStr( "\x09");
                     if (result)
                            result = m_pOut->WriteStr( pTag);
                     numStr = "*";
                     numStr.AppendInt( tagNum);
                     if (result)
                            result = m_pOut->WriteStr( numStr.get());
                     if (wasTrans && result)
                            result = m_pOut->WriteStr( "*=");
                     else if (result)
                            result = m_pOut->WriteStr( "=\"");
                     if (result)
                            result = m_pOut->WriteData( ((const PRUint8 *)fName.get()) + idx, fName.Length() - idx);
                     if (wasTrans && result)
                            result = m_pOut->WriteStr( "\x0D\x0A");
                     else if (result)
                            result = m_pOut->WriteStr( "\"\x0D\x0A");
              }
       }
       else {
              if (result)
                     result = m_pOut->WriteStr( "\x09");
              if (result)
                     result = m_pOut->WriteStr( pTag);
              if (wasTrans && result)
                     result = m_pOut->WriteStr( "*=");
              else if (result)
                     result = m_pOut->WriteStr( "=\"");
              if (result)
                     result = m_pOut->WriteStr( fName.get());
              if (wasTrans && result)
                     result = m_pOut->WriteStr( "\x0D\x0A");
              else if (result)
                     result = m_pOut->WriteStr( "\"\x0D\x0A"); 
       }

       return( result);

}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

PRBool nsImportScanFile::m_allocated [protected, inherited]

Definition at line 68 of file nsImportScanFile.h.

Definition at line 81 of file nsImportMimeEncode.h.

PRUint32 nsImportScanFile::m_bufSz [protected, inherited]

Definition at line 64 of file nsImportScanFile.h.

PRUint32 nsImportScanFile::m_bytesInBuf [protected, inherited]

Definition at line 65 of file nsImportScanFile.h.

Definition at line 79 of file nsImportMimeEncode.h.

long nsImportEncodeScan::m_dataForkSize [protected, inherited]

Definition at line 64 of file nsImportEncodeScan.h.

Definition at line 62 of file nsImportEncodeScan.h.

PRBool nsImportScanFile::m_eof [protected, inherited]

Definition at line 67 of file nsImportScanFile.h.

Definition at line 73 of file nsImportMimeEncode.h.

Definition at line 60 of file nsImportEncodeScan.h.

Definition at line 84 of file nsImportMimeEncode.h.

Definition at line 76 of file nsImportMimeEncode.h.

PRUint8* nsImportScanFile::m_pBuf [protected, inherited]

Definition at line 63 of file nsImportScanFile.h.

nsIFileSpec* nsImportScanFile::m_pFile [protected, inherited]

Definition at line 62 of file nsImportScanFile.h.

Definition at line 80 of file nsImportMimeEncode.h.

Definition at line 61 of file nsImportEncodeScan.h.

Definition at line 74 of file nsImportMimeEncode.h.

PRUint32 nsImportScanFile::m_pos [protected, inherited]

Definition at line 66 of file nsImportScanFile.h.

Definition at line 75 of file nsImportMimeEncode.h.

Definition at line 63 of file nsImportEncodeScan.h.

Definition at line 78 of file nsImportMimeEncode.h.

Definition at line 65 of file nsImportEncodeScan.h.


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