CCAsynchDiskFile Class Reference

a file class that can be used for asynchronous loading. It contains an asynchstreambuf (see above) More...

#include <ccafile.h>

Inheritance diagram for CCAsynchDiskFile:

CCDiskFile CCStreamFile CCLexFile CCFile CCObject SimpleCCObject List of all members.

Public Member Functions

 CCAsynchDiskFile (UINT32 bufferSize=CCFILE_DEFAULTSIZE, BOOL ErrorReporting=TRUE, BOOL ExceptionThrowing=FALSE)
 thread safe wrapper around CCDiskFile
 CCAsynchDiskFile (PathName fPath, INT32 fileMode, INT32 fileAccess=0, UINT32 bufferSize=CCFILE_DEFAULTSIZE, BOOL ErrorReporting=TRUE, BOOL ExceptionThrowing=FALSE)
 thread safe wrapper around CCDiskFile
 ~CCAsynchDiskFile ()
 thread safe wrapper around CCDiskFile
virtual void GotError (UINT32 errorID, const TCHAR *errorString)
 Error handler for the CCFile class. It uses flags set in the constructor to determine if the user requires errors to be reported or exceptions thrown.
virtual void GotError (UINT32 errorID)
virtual size_t Size ()
virtual BOOL eof () const
 Checks eof of the file.
void SetDownloadContext (LoadContext *pLContext)
void DownloadHasEnded (HRESULT Status)
void SetDontFail (BOOL state)

Private Member Functions

 CC_DECLARE_DYNAMIC (CCAsynchDiskFile)

Detailed Description

a file class that can be used for asynchronous loading. It contains an asynchstreambuf (see above)

Author:
Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/1993

Definition at line 185 of file ccafile.h.


Constructor & Destructor Documentation

CCAsynchDiskFile::CCAsynchDiskFile UINT32  bufferSize = CCFILE_DEFAULTSIZE,
BOOL  ErrorReporting = TRUE,
BOOL  ExceptionThrowing = FALSE
 

thread safe wrapper around CCDiskFile

CCCAsynchDiskFile

/*!

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96
Parameters:
bufferSize - Size of the fixed size buffer (default = 1024) [INPUTS]
  • if size > 0 then create a buffer of the specified size
  • if size = 0 then create a file without a buffer ReportErrors flag ThrowException flag

Definition at line 481 of file ccafile.cpp.

00483         :CCDiskFile( new async_fstream(),bufferSize, ErrorReporting,ExceptionThrowing)
00484 {                      
00485     
00486 }

CCAsynchDiskFile::CCAsynchDiskFile PathName  fPath,
INT32  fileMode,
INT32  fileAccess = 0,
UINT32  bufferSize = CCFILE_DEFAULTSIZE,
BOOL  ErrorReporting = TRUE,
BOOL  ExceptionThrowing = FALSE
 

thread safe wrapper around CCDiskFile

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96
Parameters:
bufferSize - Size of the fixed size buffer (default = 1024) [INPUTS]
  • if size > 0 then create a buffer of the specified size
  • if size = 0 then create a file without a buffer ReportErrors flag ThrowException flag

Definition at line 512 of file ccafile.cpp.

00518         :CCDiskFile(new async_fstream(),
00519                         fPath, 
00520                         fileMode, 
00521                         fileAccess,
00522                         bufferSize,
00523                         ErrorReporting,
00524                         ExceptionThrowing)
00525 {                      
00526 
00527 }

CCAsynchDiskFile::~CCAsynchDiskFile  ) 
 

thread safe wrapper around CCDiskFile

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96

Definition at line 542 of file ccafile.cpp.

00543 {
00544 
00545 }


Member Function Documentation

CCAsynchDiskFile::CC_DECLARE_DYNAMIC CCAsynchDiskFile   )  [private]
 

void CCAsynchDiskFile::DownloadHasEnded HRESULT  Status  ) 
 

Definition at line 697 of file ccafile.cpp.

00698 {   
00699     // tell the stream buf that the download is complete
00700     ((asynchstreambuf*)(IOFile->rdbuf()))->DownloadHasEnded(Status);
00701 
00702 }

BOOL CCAsynchDiskFile::eof  )  const [virtual]
 

Checks eof of the file.

Author:
Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/96

Reimplemented from CCStreamFile.

Definition at line 574 of file ccafile.cpp.

00575 {
00576     return(CCDiskFile::eof());
00577 /*  LoadContext* pLoadContext = ((asynchstreambuf*)(IOFile->rdbuf()))->GetLoadContext();
00578     if (pLoadContext->AsynchDownLoadComplete)
00579     {
00580         return(CCDiskFile::eof());
00581     }
00582 
00583     return(FALSE);*/
00584 }

void CCAsynchDiskFile::GotError UINT32  errorID  )  [virtual]
 

Reimplemented from CCFile.

Definition at line 636 of file ccafile.cpp.

00637 {
00638     if(DontFail)
00639     {
00640         IOFile->clear(0);
00641         return ;
00642     }
00643     
00644     // Expand certain types of error messages to make them more informative
00645     switch (errorID)
00646     {
00647         case _R(IDE_OPEN_ERROR):
00648         case _R(IDE_FILE_READ_ERROR):
00649         case _R(IDE_FILE_WRITE_ERROR):
00650             // Make the error message contain handy information.
00651             SetFileErrorMessage(errorID);
00652             break;
00653 
00654         case _R(IDE_ZOPEN_ERROR):
00655         case _R(IDE_ZFILE_READ_ERROR):
00656         case _R(IDE_ZFILE_WRITE_ERROR):
00657             // Make the error message contain handy information.
00658             SetZipFileErrorMessage(errorID);
00659             break;
00660 
00661         default:
00662             // Just set the error normally.
00663             Error::SetError(errorID, 0);
00664             break;
00665     }
00666 
00667     // Flag that no more reads/writes should happen by forcing bad() to return True.
00668     // So that if the user continues to access the file then they should get an error.
00669     SetBadState();
00670     
00671     // If the ReportErrors flag is set then report the error now.
00672     if (ReportErrors)
00673         InformError();
00674     
00675     // If the ThrowExceptions flag is set then throw an exception.
00676     // Use the CFileException with a generic or unknown error and make the ioserror
00677     // our error number.
00678     if (ThrowExceptions)
00679     {   
00680         TRACE( _T("CCFile GotError call to throw exception\n"));
00681         TRACEUSER( "Chris", _T("EXCEPTION!!!!!"));
00682     //  AfxThrowFileException(CFileException::generic, errorID);
00683     }
00684 }

void CCAsynchDiskFile::GotError UINT32  errorID,
const TCHAR errorString
[virtual]
 

Error handler for the CCFile class. It uses flags set in the constructor to determine if the user requires errors to be reported or exceptions thrown.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/08/94
Parameters:
Unsigned interger which is the error id and possible error message string [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: None

See also:
SetReportErrors; SetThrowExceptions

Reimplemented from CCFile.

Definition at line 605 of file ccafile.cpp.

00606 {
00607     if(DontFail)
00608     {
00609         IOFile->clear(0);
00610         return ;
00611     }
00612 
00613     ERROR3IF(errorString == 0, "errorString is null. Oh dear.");
00614 
00615     Error::SetError(errorID, errorString, 0);
00616 
00617     // Flag that no more reads/writes should happen by forcing bad() to return True/.
00618     // So that if the user continues to access the file then they should get an error.
00619     SetBadState();
00620     
00621     // If the ReportErrors flag is set then report the error now.
00622     if (ReportErrors)
00623         InformError();
00624 
00625     // If the ThrowExceptions flag is set then throw an exception.
00626     // Use the CFileException with a generic or unknown error and make the ioserror
00627     // our error number.
00628     if (ThrowExceptions)
00629     {   
00630         TRACE( _T("CCFile GotError call to throw exception\n"));
00631         TRACEUSER( "Chris", _T("EXCEPTION!!!!!"));
00632         //AfxThrowFileException(CFileException::generic, errorID);
00633     }
00634 }

void CCAsynchDiskFile::SetDontFail BOOL  state  )  [inline, virtual]
 

Reimplemented from CCLexFile.

Definition at line 218 of file ccafile.h.

00218                                 { ((asynchstreambuf*)(IOFile->rdbuf()))->SetDontFail(state);
00219                                     DontFail=state;};

void CCAsynchDiskFile::SetDownloadContext LoadContext pLContext  )  [inline]
 

Definition at line 214 of file ccafile.h.

00215         { ((asynchstreambuf*)(IOFile->rdbuf()))->SetLoadContext(pLContext);};

INT32 CCAsynchDiskFile::Size  )  [virtual]
 

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/8/96
Returns:
The size of the attached stream, in bytes.

Reimplemented from CCDiskFile.

Definition at line 556 of file ccafile.cpp.

00557 {   
00558     // we can't possibly know how big the file will be cause we haven't downloaded 
00559     // it yet - for our purposes we will return hugely big
00560     return 0xFFFFFFF;
00561 }


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:52:02 2007 for Camelot by  doxygen 1.4.4