CCFile Class Reference

Represents an abstract file class from which all other file classes will be derived. It therefore acts as a generic interface to file handling of all sorts. A routine can read or write to a CCFile object without caring whether it is a real file on disk, or to the clipboard, or to a block of RAM somewhere. This class contains many pure virtual functions, which should be implemented by the derived classes. The basic functions of this class are supplemented by the derived class CCLexFile, which provides functions to perform lexical analysis on a file object. (Note that CCLexFile is also an abstract base class.) The main use of this class will be for the export and import filters. The class and its derivatives in this file used to just call InformError() about any errors that were encountered by the routines. The caller had no control over this so the liklyhood was that users would see a number of errors instead of just one. This is still the default but now all error handling goes through a GotError function which can be made to call InformError() and/or throw an exception. This is controlled by two protected BOOL values and can be either set in the constructor or via the public SetReportErrors and SetThrowExceptions calls. GotError also tries to force the bad(), fail() functions to fail on the next call so that no more file accesses should happen. More...

#include <ccfile.h>

Inheritance diagram for CCFile:

CCObject SimpleCCObject CCLexFile CCBinHexFile CCMemFile CCStreamFile CCClipBoardFile CCMemTextFile CCResourceFile CCBufferFile CCDiskFile CCOleStream CCResTextFile CCAsynchDiskFile CCOleAccusoftStream List of all members.

Public Member Functions

 CCFile (BOOL ErrorReporting=TRUE, BOOL ExceptionThrowing=FALSE)
 Default CCFile class constructor. Does nothing but set the reporting flags.
virtual ~CCFile ()
virtual BOOL setMode (INT32 fileMode=0)=0
virtual BOOL isOpen () const =0
virtual CCFileseekIn (FilePos)=0
virtual CCFileseekIn (INT32 Offset, ios::seekdir Dir)=0
virtual FilePos tellIn ()=0
virtual CCFileseek (FilePos pos)=0
virtual FilePos tell ()=0
virtual CCFileread (void *buf, UINT32 length=1)=0
virtual CCFileread (StringBase *buf)=0
virtual CCFileread (char &buf)=0
virtual CCFilewrite (const void *buf, UINT32 length=1)=0
virtual CCFilewrite (const StringBase &buf, UINT32 length=0)=0
virtual CCFilewrite (char &buf)=0
virtual size_t Size ()=0
virtual BOOL eof () const =0
virtual void close ()=0
virtual BOOL good () const
 Simple base implentation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).
virtual BOOL bad () const
 Simple base implementation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).
virtual BOOL fail () const
 Simple base implementation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).
virtual void SetBadState ()=0
virtual void SetGoodState ()=0
virtual iostream * GetIOFile ()=0
virtual CCFileflush ()
 Flushes a file's buffers. By default it does nothing - override it if you want it to do anything. (The CCDiskFile class overrides this function.).
virtual CCFileget (char &)
virtual CCFileput (const char &)
virtual CCFileoperator>> (StringBase *buf)
 Reads file until string buffer is full or end of line or end of file is met.
virtual CCFileoperator<< (const StringBase &buf)
 Writes the charactors found in the String buffer.
 operator void * () const
INT32 operator! () const
virtual BOOL SetReportErrors (BOOL)
 Public way of setting the internal error handling flag to say whether errors are going to be reported or not.
virtual BOOL SetThrowExceptions (BOOL)
 Public way of setting the internal error handling flag to say whether errors are going to throw an exception or not.
virtual BOOL IsReportingSet ()
 Public way of checking the internal error reporting flag to say whether InformError is going to be called or not.
virtual BOOL IsThrowingSet ()
 Public way of checking the internal error throwing flag to say whether errors are going to throw an exception or not.
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 BOOL GetName (StringBase *) const
 Given a CCFile*, you can ask for some sort of name which is associated with that file. For filenames it might be a filename, or a pathname, for resource files it might be "Default Bitmap" etc. These names could then be used for making error messages have some extra useful information in.
virtual PathName GetPathName () const
virtual BOOL SetFileErrorMessage (UINT32 ErrorID)
 Looks at the 'errno' variable to determine what kind of error occured, and uses the specified error resource string to make a helpful error message out of it. NB. The string must have two string fields, to be replaced as follows: #1s = description of error #2s = name of the file that went wrong.
virtual BOOL SetZipFileErrorMessage (UINT32 ErrorID)
 Looks at the 'GZipErrorID' variable to determine what kind of error occured, and uses the specified error resource string to make a helpful error message out of it. NB. The string must have two string fields, to be replaced as follows: #1s = description of error #2s = name of the file that went wrong.
virtual filedesc GetFileHandle () const =0
virtual BOOL IsCompressionSet ()
 Allow the reading of the compression flag to see if all output data is compressed or not.
virtual BOOL SetCompression (BOOL)
 Allow the setting of the compression flag so that all output data is compressed.
virtual BOOL InitCompression (BOOL Header=FALSE)=0
virtual BOOL StartCompression ()=0
virtual BOOL StopCompression ()=0

Protected Attributes

BOOL ReportErrors
BOOL ThrowExceptions
BOOL CompressData
UINT32 GZipErrorID

Private Member Functions

 CC_DECLARE_DYNAMIC (CCFile)

Detailed Description

Represents an abstract file class from which all other file classes will be derived. It therefore acts as a generic interface to file handling of all sorts. A routine can read or write to a CCFile object without caring whether it is a real file on disk, or to the clipboard, or to a block of RAM somewhere. This class contains many pure virtual functions, which should be implemented by the derived classes. The basic functions of this class are supplemented by the derived class CCLexFile, which provides functions to perform lexical analysis on a file object. (Note that CCLexFile is also an abstract base class.) The main use of this class will be for the export and import filters. The class and its derivatives in this file used to just call InformError() about any errors that were encountered by the routines. The caller had no control over this so the liklyhood was that users would see a number of errors instead of just one. This is still the default but now all error handling goes through a GotError function which can be made to call InformError() and/or throw an exception. This is controlled by two protected BOOL values and can be either set in the constructor or via the public SetReportErrors and SetThrowExceptions calls. GotError also tries to force the bad(), fail() functions to fail on the next call so that no more file accesses should happen.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/1993 Base Class: CCObject
See also:
CCLexFile; CCDiskFile; CCMemFile; CCMemTextFile

Definition at line 171 of file ccfile.h.


Constructor & Destructor Documentation

CCFile::CCFile BOOL  ErrorReporting = TRUE,
BOOL  ExceptionThrowing = FALSE
 

Default CCFile class constructor. Does nothing but set the reporting flags.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/08/94
Parameters:
Flags to specify whether reporting errors or throwing exceptions. [INPUTS] Defaults specified to backward compatible. Set to report errors but not to throw exceptions.
None [OUTPUTS]
Returns:
None

Errors: None

Definition at line 155 of file ccfile.cpp.

00156 {
00157     // Set our class variables from the passed in values
00158     ReportErrors = ErrorReporting;
00159     ThrowExceptions = ExceptionThrowing;
00160 
00161     // Default to no compression
00162     CompressData = FALSE;
00163     // Default to no GZipErrorID
00164     GZipErrorID = 0;
00165 }

virtual CCFile::~CCFile  )  [inline, virtual]
 

Definition at line 178 of file ccfile.h.

00178 { /* empty */ }


Member Function Documentation

BOOL CCFile::bad  )  const [virtual]
 

Simple base implementation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Returns:
TRUE => An error has occured. FALSE => The file stream is ok.

Reimplemented in CCBinHexFile, CCStreamFile, and CCMemFile.

Definition at line 751 of file ccfile.cpp.

00752 {
00753     return eof();
00754 }

CCFile::CC_DECLARE_DYNAMIC CCFile   )  [private]
 

virtual void CCFile::close  )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, CCOleStream, CCDiskFile, CCMemFile, CCResTextFile, and CCClipBoardFile.

virtual BOOL CCFile::eof  )  const [pure virtual]
 

Implemented in CCAsynchDiskFile, CCBinHexFile, CCStreamFile, CCMemFile, CCMemTextFile, CCResTextFile, and CCClipBoardFile.

BOOL CCFile::fail  )  const [virtual]
 

Simple base implementation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Returns:
TRUE => An error has occured. FALSE => The file stream is ok.

Reimplemented in CCBinHexFile, CCStreamFile, and CCMemFile.

Definition at line 772 of file ccfile.cpp.

00773 {
00774     return eof();
00775 }

CCFile & CCFile::flush  )  [virtual]
 

Flushes a file's buffers. By default it does nothing - override it if you want it to do anything. (The CCDiskFile class overrides this function.).

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Returns:
Reference to the CCFile object.
See also:
CCDiskFile::flush

Reimplemented in CCBinHexFile, and CCStreamFile.

Definition at line 709 of file ccfile.cpp.

00710 {
00711     return (CCFile&) *this;
00712 }

CCFile & CCFile::get char &   )  [virtual]
 

Reimplemented in CCStreamFile.

Definition at line 686 of file ccfile.cpp.

00687 {
00688     return read(buf);
00689 }

virtual filedesc CCFile::GetFileHandle  )  const [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, CCDiskFile, and CCMemFile.

virtual iostream* CCFile::GetIOFile  )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, and CCMemFile.

BOOL CCFile::GetName StringBase name  )  const [virtual]
 

Given a CCFile*, you can ask for some sort of name which is associated with that file. For filenames it might be a filename, or a pathname, for resource files it might be "Default Bitmap" etc. These names could then be used for making error messages have some extra useful information in.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/09/94
Parameters:
Pointer to a CCFile name [INPUTS]
None [OUTPUTS]
Returns:
True if a name has been set otherwise False. At present always returns False.

Errors: None

Reimplemented in CCDiskFile, and CCMemFile.

Definition at line 624 of file ccfile.cpp.

00625 {
00626     return FALSE;
00627 }

PathName CCFile::GetPathName  )  const [virtual]
 

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/8/96
Returns:
The path-name of this file. If the file doesn't support the notion of a file-path (as, for instance, CCMemFiles and CCStreamFiles), then returns an empty string.

Reimplemented in CCDiskFile.

Definition at line 641 of file ccfile.cpp.

00642 {
00643     PathName pn;
00644     return pn;
00645 }

BOOL CCFile::good  )  const [virtual]
 

Simple base implentation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Returns:
TRUE => file stream is ok. FALSE => an error has occured.

Reimplemented in CCBinHexFile, CCStreamFile, and CCMemFile.

Definition at line 730 of file ccfile.cpp.

00731 {
00732     return !eof();
00733 }

void CCFile::GotError UINT32  errorID  )  [virtual]
 

Reimplemented in CCAsynchDiskFile.

Definition at line 274 of file ccfile.cpp.

00275 {
00276     // Expand certain types of error messages to make them more informative
00277     if ((errorID == _R(IDE_OPEN_ERROR)) ||
00278         (errorID == _R(IDE_FILE_READ_ERROR)) ||
00279         (errorID == _R(IDE_FILE_WRITE_ERROR)) )
00280         // Make the error message contain handy information.
00281         SetFileErrorMessage(errorID);
00282     else if ((errorID == _R(IDE_ZOPEN_ERROR) ) ||
00283         (errorID == _R(IDE_ZFILE_READ_ERROR)) ||
00284         (errorID == _R(IDE_ZFILE_WRITE_ERROR)) )
00285         // Make the error message contain handy information.
00286         SetZipFileErrorMessage(errorID);
00287     else
00288         Error::SetError(errorID, 0);
00289 
00290     // Flag that no more reads/writes should happen by forcing bad() to return True.
00291     // So that if the user continues to access the file then they should get an error.
00292     SetBadState();
00293     
00294 #if !defined(EXCLUDE_FROM_XARLIB)
00295     // If the ReportErrors flag is set then report the error now.
00296     if (ReportErrors)
00297         InformError();
00298 #endif
00299     
00300     // If the ThrowExceptions flag is set then throw an exception.
00301     // Use the CFileException with a generic or unknown error and make the ioserror
00302     // our error number.
00303     if (ThrowExceptions)
00304     {   
00305         TRACE( _T("CCFile GotError call to throw exception\n") );
00306         //TRACEUSER( "Chris", _T("EXCEPTION!!!!!"));
00307         //AfxDebugBreak();
00308         throw( CFileException( errorID ) );
00309     }
00310 }

void CCFile::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 in CCAsynchDiskFile.

Definition at line 246 of file ccfile.cpp.

00247 {
00248     ERROR3IF(errorString == 0, "errorString is null. Oh dear.");
00249 
00250     Error::SetError(errorID, errorString, 0);
00251 
00252     // Flag that no more reads/writes should happen by forcing bad() to return True/.
00253     // So that if the user continues to access the file then they should get an error.
00254     SetBadState();
00255     
00256 #if !defined(EXCLUDE_FROM_XARLIB)
00257     // If the ReportErrors flag is set then report the error now.
00258     if (ReportErrors)
00259         InformError();
00260 #endif
00261 
00262     // If the ThrowExceptions flag is set then throw an exception.
00263     // Use the CFileException with a generic or unknown error and make the ioserror
00264     // our error number.
00265     if (ThrowExceptions)
00266     {   
00267         TRACE( _T("CCFile GotError call to throw exception\n") );
00268     
00269         throw( CFileException( errorID ) );
00270 //      AfxThrowFileException(CFileException::generic, errorID);
00271     }
00272 }

virtual BOOL CCFile::InitCompression BOOL  Header = FALSE  )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, and CCMemFile.

BOOL CCFile::IsCompressionSet  )  [virtual]
 

Allow the reading of the compression flag to see if all output data is compressed or not.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/08/94
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
The state of the compression flag, TRUE if compression is on.

Reimplemented in CCBinHexFile.

Definition at line 181 of file ccfile.cpp.

00182 {
00183     return CompressData;
00184 }   

virtual BOOL CCFile::isOpen  )  const [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, CCOleStream, CCDiskFile, and CCMemFile.

BOOL CCFile::IsReportingSet  )  [virtual]
 

Public way of checking the internal error reporting flag to say whether InformError is going to be called or not.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/09/94
Parameters:
None. [INPUTS]
None [OUTPUTS]
Returns:
True if error reporting flag is set.

Errors: None

See also:
GotError; SetReportErrors; SetThrowExceptions

Definition at line 582 of file ccfile.cpp.

00583 {
00584     return ReportErrors;
00585 }

BOOL CCFile::IsThrowingSet  )  [virtual]
 

Public way of checking the internal error throwing flag to say whether errors are going to throw an exception or not.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/09/94
Parameters:
None. [INPUTS]
None [OUTPUTS]
Returns:
True if exception throwing flag is set.

Errors: None

See also:
GotError; SetReportErrors; SetThrowExceptions

Definition at line 602 of file ccfile.cpp.

00603 {
00604     return ThrowExceptions;
00605 }

CCFile::operator void *  )  const [inline]
 

Definition at line 241 of file ccfile.h.

00241 { return fail() ? 0 : (void*) this; }

INT32 CCFile::operator!  )  const [inline]
 

Definition at line 242 of file ccfile.h.

00242 { return fail(); }

CCFile & CCFile::operator<< const StringBase buf  )  [virtual]
 

Writes the charactors found in the String buffer.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/9/93
Parameters:
buf - the string to write out to the file. [INPUTS]
Returns:
Reference to the CCFile object.
See also:
CCFile::write

Definition at line 680 of file ccfile.cpp.

00681 {
00682     return write(buf);
00683 }

CCFile & CCFile::operator>> StringBase buf  )  [virtual]
 

Reads file until string buffer is full or end of line or end of file is met.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/9/93
Parameters:
String buffer. [INPUTS]
Returns:
Reference to the CCFile object.
See also:
CCFile::read

Definition at line 662 of file ccfile.cpp.

00663 {
00664     return read(buf);
00665 }

CCFile & CCFile::put const char &   )  [virtual]
 

Reimplemented in CCStreamFile.

Definition at line 691 of file ccfile.cpp.

00692 {
00693     return write((void *) &buf);
00694 }

virtual CCFile& CCFile::read char &  buf  )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, CCMemFile, CCMemTextFile, CCResTextFile, and CCClipBoardFile.

virtual CCFile& CCFile::read StringBase buf  )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, CCMemFile, CCMemTextFile, CCResTextFile, and CCClipBoardFile.

virtual CCFile& CCFile::read void *  buf,
UINT32  length = 1
[pure virtual]
 

Implemented in CCBinHexFile, CCBufferFile, CCStreamFile, and CCMemFile.

virtual CCFile& CCFile::seek FilePos  pos  )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, and CCMemFile.

virtual CCFile& CCFile::seekIn INT32  Offset,
ios::seekdir  Dir
[pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, and CCMemFile.

virtual CCFile& CCFile::seekIn FilePos   )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, and CCMemFile.

virtual void CCFile::SetBadState  )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, and CCMemFile.

BOOL CCFile::SetCompression BOOL  NewState  )  [virtual]
 

Allow the setting of the compression flag so that all output data is compressed.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/08/94
Parameters:
TRUE if want compression, false otherhwise. [INPUTS]
None [OUTPUTS]
Returns:
True, if it was successful, False otherwise.

Reimplemented in CCBinHexFile.

Definition at line 200 of file ccfile.cpp.

00201 {
00202 //  BOOL OldState = CompressData;
00203 
00204     CompressData = NewState;
00205 
00206     BOOL ok = TRUE;
00207     
00208     // If turning compression On then start the compression up
00209     // else turn it off.
00210     if (NewState)
00211     {
00212         // Get the class itself to start the compression process up
00213         ok = StartCompression();
00214         if (!ok)
00215         {
00216             CompressData = FALSE;   
00217         }
00218     }
00219     else
00220     {
00221         // Get the class itself to start the compression process up
00222         ok = StopCompression();
00223     }
00224 
00225     return ok;  
00226 }

BOOL CCFile::SetFileErrorMessage UINT32  ErrorID  )  [virtual]
 

Looks at the 'errno' variable to determine what kind of error occured, and uses the specified error resource string to make a helpful error message out of it. NB. The string must have two string fields, to be replaced as follows: #1s = description of error #2s = name of the file that went wrong.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/11/94
Parameters:
ErrorID - the ID of the string resource to use as the error message. [INPUTS]
Returns:
TRUE if the error message was constructed ok; FALSE if not (e.g. string resource did not load).
An example is _R(IDE_FILE_READ_ERROR):

"A read error occured (#1%s) with the file: #2%s"

See also:
CCFile::GotError

Definition at line 338 of file ccfile.cpp.

00339 {
00340     UINT32 FileErrorID;
00341 
00342     // Work out which error description string to use...
00343     switch (errno)
00344     {
00345         case EACCES:
00346             // Permission denied
00347             FileErrorID = _R(IDE_FILE_PERM_DENIED);
00348             break;
00349 
00350         case EBADF:
00351             // Bad file number
00352             FileErrorID = _R(IDE_FILE_BAD_FILE);
00353             break;
00354 
00355         case EEXIST:
00356             // File already exists
00357             FileErrorID = _R(IDE_FILE_EXISTS);
00358             break;
00359 
00360         case EMFILE:
00361             // Too many open files
00362             FileErrorID = _R(IDE_FILE_TOO_MANY_OPEN);
00363             break;
00364 
00365         case ENOENT:
00366             // No such file or directory
00367             FileErrorID = _R(IDE_FILE_NO_EXIST);
00368             break;
00369 
00370         case ENOSPC:
00371             // No space left on device
00372             FileErrorID = _R(IDE_FILE_NO_SPACE);
00373             break;
00374 
00375         default:
00376             // Unknown error
00377             FileErrorID = _R(IDE_FILE_UNKNOWN);
00378     }
00379 
00380     // Load in this resource
00381     String_64 FileError;
00382 
00383     if (!FileError.Load(FileErrorID))
00384     {
00385         // Error occured - just use the error number
00386         if( FileError._MakeMsg( _T("#1%d"), errno ) == 0 )
00387             // Couldn't do this (we must be severely shafted by now!) - return error
00388             return FALSE;
00389     }
00390 
00391     // Get a shortened name for the file
00392     String_64 Filename;
00393 
00394     if (!GetName(&Filename))
00395     {
00396         // Unable to get a name - substitute with "unknown"
00397         if (!Filename.Load(_R(IDE_FILE_UNKNOWN)))
00398         {
00399             // Error occured - just use the hard-coded literal "unknown"
00400             // (This was sanctioned by Phil)
00401             Filename = TEXT("unknown");
00402         }
00403     }
00404 
00405     // Use this information to build an error string and pass it to the SetError() function.
00406     String_256 ErrorMsg;
00407 
00408     if (ErrorMsg.MakeMsg(ErrorID, (LPCTSTR) FileError, (LPCTSTR) Filename) == 0)
00409         // Error occured - maybe resource would not load...not much we can do now.
00410         return FALSE;
00411 
00412     Error::SetError(ErrorID, (TCHAR *) ErrorMsg, 0);
00413 
00414     // Error string was constructed ok
00415     return TRUE;
00416 }

virtual void CCFile::SetGoodState  )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, and CCMemFile.

virtual BOOL CCFile::setMode INT32  fileMode = 0  )  [pure virtual]
 

Implemented in CCBinHexFile, CCBufferFile, CCStreamFile, CCOleStream, CCDiskFile, and CCMemFile.

BOOL CCFile::SetReportErrors BOOL  newState  )  [virtual]
 

Public way of setting the internal error handling flag to say whether errors are going to be reported or not.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/08/94
Parameters:
BOOL which is the TRUE/FALSE state required. [INPUTS]
None [OUTPUTS]
Returns:
Old state of the flag

Errors: None

See also:
GotError; IsReportingSet; IsThrowingSet

Definition at line 534 of file ccfile.cpp.

00535 {
00536     BOOL OldState = ReportErrors;
00537 
00538     ReportErrors = newState;
00539 
00540     return OldState;
00541 }

BOOL CCFile::SetThrowExceptions BOOL  newState  )  [virtual]
 

Public way of setting the internal error handling flag to say whether errors are going to throw an exception or not.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/08/94
Parameters:
BOOL which is the TRUE/FALSE state required. [INPUTS]
None [OUTPUTS]
Returns:
Old state of the flag

Errors: None

See also:
GotError; IsReportingSet; IsThrowingSet

Definition at line 558 of file ccfile.cpp.

00559 {
00560     BOOL OldState = ThrowExceptions;
00561 
00562     ThrowExceptions = newState;
00563 
00564     return OldState;
00565 }

BOOL CCFile::SetZipFileErrorMessage UINT32  ErrorID  )  [virtual]
 

Looks at the 'GZipErrorID' variable to determine what kind of error occured, and uses the specified error resource string to make a helpful error message out of it. NB. The string must have two string fields, to be replaced as follows: #1s = description of error #2s = name of the file that went wrong.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/6/94
Parameters:
ErrorID - the ID of the string resource to use as the error message. [INPUTS]
Returns:
TRUE if the error message was constructed ok; FALSE if not (e.g. string resource did not load).
An example is _R(IDE_FILE_READ_ERROR):

"A read error occured (#1%s) with the file: #2%s"

Exactly the same as above but is designed for zip file errors.

See also:
SetFileErrorMessage; CCFile::GotError

Definition at line 444 of file ccfile.cpp.

00445 {
00446     UINT32 ZipFileErrorID;
00447 
00448     // Work out which error description string to use...
00449     switch (GZipErrorID)
00450     {
00451         case Z_ERRNO:
00452             // Bad file number
00453             ZipFileErrorID = _R(IDE_ZFILE_ERRORNO);
00454             break;
00455 
00456         case Z_STREAM_ERROR:
00457             // Permission denied
00458             ZipFileErrorID = _R(IDE_ZFILE_STREAMERROR);
00459             break;
00460 
00461         case Z_DATA_ERROR:
00462             // Bad file number
00463             ZipFileErrorID = _R(IDE_ZFILE_DATAERROR);
00464             break;
00465 
00466         case Z_MEM_ERROR:
00467             // Bad file number
00468             ZipFileErrorID = _R(IDE_ZFILE_MEMORYERROR);
00469             break;
00470 
00471         case Z_BUF_ERROR:
00472             // Bad file number
00473             ZipFileErrorID = _R(IDE_ZFILE_BUFFERERROR);
00474             break;
00475 
00476         default:
00477             // Unknown error
00478             ZipFileErrorID = _R(IDE_ZFILE_BASEEERROR);
00479     }
00480 
00481     // Load in this resource
00482     String_64 FileError;
00483 
00484     if (!FileError.Load(ZipFileErrorID))
00485     {
00486         // Error occured - just use the error number
00487         if( FileError._MakeMsg( _T("#1%d"), errno ) == 0 )
00488             // Couldn't do this (we must be severely shafted by now!) - return error
00489             return FALSE;
00490     }
00491 
00492     // Get a shortened name for the file
00493     String_32 Filename;
00494 
00495     if (!GetName(&Filename))
00496     {
00497         // Unable to get a name - substitute with "unknown"
00498         if (!Filename.Load(_R(IDE_FILE_UNKNOWN)))
00499         {
00500             // Error occured - just use the hard-coded literal "unknown"
00501             // (This was sanctioned by Phil)
00502             Filename = TEXT("unknown");
00503         }
00504     }
00505 
00506     // Use this information to build an error string and pass it to the SetError() function.
00507     String_256 ErrorMsg;
00508 
00509     if (ErrorMsg.MakeMsg(ErrorID, (LPCTSTR) FileError, (LPCTSTR) Filename) == 0)
00510         // Error occured - maybe resource would not load...not much we can do now.
00511         return FALSE;
00512 
00513     Error::SetError(ErrorID, (TCHAR *) ErrorMsg, 0);
00514 
00515     // Error string was constructed ok
00516     return TRUE;
00517 }

virtual size_t CCFile::Size  )  [pure virtual]
 

Implemented in CCAsynchDiskFile, CCBinHexFile, CCStreamFile, CCOleStream, CCDiskFile, and CCMemFile.

virtual BOOL CCFile::StartCompression  )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, and CCMemFile.

virtual BOOL CCFile::StopCompression  )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, and CCMemFile.

virtual FilePos CCFile::tell  )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, and CCMemFile.

virtual FilePos CCFile::tellIn  )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, and CCMemFile.

virtual CCFile& CCFile::write char &  buf  )  [pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, and CCMemFile.

virtual CCFile& CCFile::write const StringBase buf,
UINT32  length = 0
[pure virtual]
 

Implemented in CCBinHexFile, CCStreamFile, CCMemFile, CCMemTextFile, and CCClipBoardFile.

virtual CCFile& CCFile::write const void *  buf,
UINT32  length = 1
[pure virtual]
 

Implemented in CCBinHexFile, CCBufferFile, CCStreamFile, and CCMemFile.


Member Data Documentation

BOOL CCFile::CompressData [protected]
 

Definition at line 279 of file ccfile.h.

UINT32 CCFile::GZipErrorID [protected]
 

Definition at line 280 of file ccfile.h.

BOOL CCFile::ReportErrors [protected]
 

Definition at line 276 of file ccfile.h.

BOOL CCFile::ThrowExceptions [protected]
 

Definition at line 277 of file ccfile.h.


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