ccafile.cpp

Go to the documentation of this file.
00001 // $Id: ccafile.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 
00100 
00101 #include "camtypes.h"
00102 
00103 #include "ccafile.h"
00104 
00105 #include <errno.h>
00106 
00107 //#include "ensure.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "mario.h"
00110 //#include "tim.h"
00111 
00112 #include "zstream.h"
00113 //#include "nev.h"
00114 //#include "ralphint.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00115 #include "ralphdoc.h"
00116                         
00117 DECLARE_SOURCE("$Revision: 1282 $");
00118 
00119 CC_IMPLEMENT_DYNAMIC(CCAsynchDiskFile, CCDiskFile);
00120 
00121 
00122 PORTNOTE("other","CAM_DEBUG_NEW won't work")
00123 #ifndef EXCLUDE_FROM_XARALX
00124 #define new CAM_DEBUG_NEW
00125 #endif
00126 #define ME "Chris"
00127 
00128 /********************************************************************************************
00129 
00130 >   asynchstreambuf::~asynchstreambuf()
00131 
00132 
00133     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00134     Created:    21/08/96
00135     Purpose:    constructor
00136 
00137 ********************************************************************************************/
00138 
00139 asynchstreambuf::asynchstreambuf()
00140 {   
00141     
00142     
00143     DontFail = FALSE;
00144 }
00145 
00146 /********************************************************************************************
00147 
00148 >   asynchstreambuf::~asynchstreambuf()
00149 
00150 
00151     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00152     Created:    21/08/96
00153     Purpose:    destructor - clean up event and critical section
00154 
00155 ********************************************************************************************/
00156 
00157 asynchstreambuf::~asynchstreambuf()
00158 {
00159     
00160 }
00161 /********************************************************************************************
00162 
00163 >   asynchstreambuf::::SetLoadContext(LoadContext *pLContext)
00164 
00165     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00166     Created:    21/08/96
00167     Purpose:    attach a load context for this buffer (used to syb#nchorise the read and write 
00168                 threads) and initialise the handle array used in WaitForMulitpleObjects()
00169 
00170 ********************************************************************************************/
00171 
00172 void asynchstreambuf::SetLoadContext(LoadContext *pLContext)
00173 { 
00174 
00175     pLoadContext= pLContext;
00176     WakeEvents[0] = RalphDocument::g_hAbortDownLoadEvent;
00177     WakeEvents[1] = pLoadContext->hDataAvailableEvent;
00178 
00179 
00180 }
00181 
00182 
00183 /********************************************************************************************
00184 
00185 >   asynchstreambuf:: seekoff(streamoff sOff,ios::seekdir eDir,INT32 mode)
00186 
00187     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00188     Created:    21/08/96
00189     Inputs:     Standard streambuf
00190     Purpose:    before the normal seek operation is attempted we test to see whether it is
00191                 possible - if not this thread will wait until a "xsputn" wakes us -
00192 
00193 ********************************************************************************************/
00194 
00195 
00196 streampos  asynchstreambuf::seekoff(streamoff sOff,ios::seekdir eDir,INT32 mode)
00197 {
00198 
00199     if(pLoadContext == NULL)
00200         return 0;
00201 
00202     // test whether this seek can succeed and sleep if not
00203     // the write thread will wake us with a hDataAvailableEvent
00204     while(sOff>pLoadContext->TotalBytes && !pLoadContext->AsynchDownLoadComplete)
00205     {
00206         
00207         TRACEUSER( ME, _T("can't seekoff - go to sleep.... \n"));
00208         
00209         // note this is an auto-reset event
00210         // i.e. it will clear after this call returns... 
00211         DWORD we = WaitForMultipleObjects(2,WakeEvents,FALSE,INFINITE);
00212         
00213         // the EndDownLoad event - set the flag
00214         if(we == WAIT_OBJECT_0)
00215         {
00216             pLoadContext->AsynchDownLoadComplete = TRUE;
00217             TRACEUSER( "Chris", _T("...... Abort thread %x \n"),::GetCurrentThreadId());
00218         }
00219         
00220     }
00221 
00222     // return the absolute file position
00223     streampos retPos = filebuf::seekoff(sOff,eDir,mode);
00224     
00225     pLoadContext->BytesAvailable = pLoadContext->TotalBytes - retPos ;
00226 
00227     TRACEUSER( ME, _T("seekoff to %d Bytes Available = %d\n"),sOff,pLoadContext->BytesAvailable); 
00228 
00229     return retPos ;
00230 
00231 }
00232 
00233 /********************************************************************************************
00234 
00235 >   asynchstreambuf::seekpos(streampos sPos,INT32 mode)
00236 
00237     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00238     Created:    21/08/96
00239     Inputs:     Standard streambuf
00240     Purpose:    before the normal seek operation is attempted we test to see whether it is
00241                 possible - if not this thread will wait until a "xsputn" wakes us -
00242 
00243 ********************************************************************************************/
00244 
00245 streampos  asynchstreambuf::seekpos(streampos sPos,INT32 mode)
00246 {
00247 
00248     
00249     if(pLoadContext == NULL)
00250         return 0;
00251 
00252 
00253     // test whether this seek can succeed - sleep if not
00254     // the write thread will wake us with a hDataAvailableEvent
00255     while(sPos>=pLoadContext->TotalBytes && !pLoadContext->AsynchDownLoadComplete)
00256     {
00257         
00258         TRACEUSER( ME, _T("can't seekpos - go to sleep.... \n"));
00259         
00260         // note this is an auto-reset event
00261         // i.e. it will clear after this call returns... 
00262         DWORD we = WaitForMultipleObjects(2,WakeEvents,FALSE,INFINITE);
00263         
00264         // the EndDownLoad event - set the flag
00265         if(we == WAIT_OBJECT_0)
00266         {
00267             pLoadContext->AsynchDownLoadComplete = TRUE;
00268             TRACEUSER( "Chris", _T("...... Abort thread %x \n"),::GetCurrentThreadId());
00269         }
00270         
00271     }
00272 
00273     // return the absolute file position
00274     streampos retPos = filebuf::seekpos(sPos,mode);
00275     
00276     pLoadContext->BytesAvailable = pLoadContext->TotalBytes - retPos;
00277     
00278     TRACEUSER( ME, _T("seekpos to %d Bytes Available = %d\n"),sPos,pLoadContext->BytesAvailable); 
00279 
00280     return retPos;
00281 }
00282 
00283 
00284 /********************************************************************************************
00285 
00286 >   CCFile& asynchstreambuf::xsputn(char * c,INT32 n)
00287 
00288     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00289     Created:    21/08/96
00290     Purpose:    the 'write' function - wake the read thread
00291 
00292 ********************************************************************************************/
00293 
00294 INT32  asynchstreambuf::xsputn(const char * c,INT32 n)
00295 {
00296 
00297     
00298     if(pLoadContext == NULL)
00299         return 0;
00300 
00301 
00302     //for(INT32 i=0;i<n;i++)
00303     //  TRACEUSER( ME, _T("%c"),c[i]);
00304 
00305     INT32 ret = filebuf::xsputn(c,n);
00306     
00307     
00308     // total available
00309     pLoadContext->BytesAvailable+=ret;
00310     
00311     // absolute total
00312     pLoadContext->TotalBytes+=ret;
00313 
00314     TRACEUSER( ME, _T("Put TotalBytes = %d BytesAvailable = %d\n"),pLoadContext->TotalBytes,pLoadContext->BytesAvailable); 
00315 
00316     // flush the buffer - otherwise xsgetn might try to read data that is still buffered
00317     sync();
00318 
00319     // wake the read thread
00320     SetEvent(pLoadContext->hDataAvailableEvent);
00321 
00322     return ret;
00323 }
00324 /********************************************************************************************
00325 
00326 >   CCFile& asynchstreambuf::xsgetn(char * c,INT32 n)
00327 
00328     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00329     Created:    21/08/96
00330     Purpose:    the 'read' function - block if data is not available
00331 
00332 ********************************************************************************************/
00333 
00334 INT32  asynchstreambuf::xsgetn(char * c,INT32 n)
00335 {
00336 
00337 
00338     if(pLoadContext == NULL)
00339         return 0;
00340 
00341 /*  if(pLoadContext->BytesAvailable == 0)
00342     {
00343         AfxDebugBreak();
00344     }*/
00345 
00346     TRACEUSER( ME, _T("request %d Get - Bytes Available = %d\n"),n,pLoadContext->BytesAvailable); 
00347 
00348     // test whether this read can succed and sleep if not
00349     // the write thread will wake us with a hDataAvailableEvent
00350     while(!DataAvailable(n)&& !pLoadContext->AsynchDownLoadComplete)
00351     {
00352         
00353         TRACEUSER( "Chris", _T("###### Waiting in thread %x \n"),::GetCurrentThreadId());
00354         
00355         // note this is an auto-reset event
00356         // i.e. it will clear after this call returns... 
00357     
00358         DWORD we = WaitForMultipleObjects(2,WakeEvents,FALSE,INFINITE);
00359         
00360         // the EndDownLoad event - set the flag
00361         if(we == WAIT_OBJECT_0)
00362         {
00363             pLoadContext->AsynchDownLoadComplete = TRUE;
00364             TRACEUSER( "Chris", _T("...... Abort thread %x \n"),::GetCurrentThreadId());
00365         }
00366         
00367         TRACEUSER( "Chris", _T("###### Wake thread %x \n"),::GetCurrentThreadId());
00368         
00369             
00370     }
00371     
00372         
00373     if(DontFail && pLoadContext->BytesAvailable<n)
00374     {   
00375         n = pLoadContext->BytesAvailable;
00376     
00377     }
00378 
00379     if(pLoadContext->TotalBytes == 0)
00380     {
00381         return n;
00382     }
00383 
00384     INT32 ret = filebuf::xsgetn(c,n);
00385     
00386         
00387 
00388     TRACEUSER( ME, _T("received   %d \n"),ret); 
00389 
00390 
00391 //  if(ret==1)
00392 //      TRACEUSER( ME, _T("%c"),*c);
00393  
00394     
00395     // decrement  bytes available after the read
00396     pLoadContext->BytesAvailable -= ret;
00397 
00398     return ret;
00399 }
00400 
00401 /********************************************************************************************
00402 
00403 >   CCFile& asynchstreambuf::DataNotAvailable()
00404 
00405     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00406     Created:    21/08/96
00407     Purpose:    
00408 
00409 ********************************************************************************************/
00410 
00411 BOOL asynchstreambuf::DataAvailable(INT32 Length)
00412 {   
00413     
00414 
00415     if(pLoadContext == NULL)
00416         return 0;
00417 
00418     //TRACEUSER( ME, _T("asking for %d got  = %d\n"),Length,BytesAvailable); 
00419 
00420     //UINT32 BufferAvail = (UINT32)(IOFile->rdbuf()->in_avail());
00421     if (pLoadContext->BytesAvailable > Length) 
00422     {
00423         //  TRACEUSER( ME, _T("YES Data Available !!! \n"));
00424         return TRUE ;   
00425     }
00426 
00427     //TRACEUSER( ME, _T("NO Data Available \n"));
00428     return FALSE;
00429 }
00430 
00431 
00432 /********************************************************************************************
00433 
00434 >   void CCAsynchDiskFile::DownloadHasEnded(HRESULT Status)
00435     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00436     Created:    21/08/96
00437     Purpose:    
00438 
00439 ********************************************************************************************/
00440 
00441 void asynchstreambuf::DownloadHasEnded(HRESULT Status)
00442 {   
00443 
00444 
00445     if(pLoadContext == NULL)
00446         return ;
00447 
00448     // set the exit state - this will be tested in in all the wait loops
00449     pLoadContext->AsynchDownLoadComplete = TRUE;
00450     
00451     TRACEUSER( "Chris", _T("###### Waking thread %x \n"),::GetCurrentThreadId());
00452         
00453     
00454     // wake the read thread
00455     SetEvent(pLoadContext->hDataAvailableEvent);
00456 }
00457 
00458 
00459 
00460 
00461 /********************************************************************************************
00462 
00463                                         CCCAsynchDiskFile
00464 
00465 /********************************************************************************************
00466 
00467 >   CCAsynchDiskFile::CCDiskFile(UINT32 bufferSize,
00468                            BOOL ErrorReporting = TRUE, BOOL ExceptionThrowing = FALSE)
00469 
00470     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00471     Created:    21/08/96
00472     Inputs:     bufferSize  - Size of the fixed size buffer (default = 1024)
00473                             - if size > 0 then create a buffer of the specified size
00474                             - if size = 0 then create a file without a buffer
00475                 ReportErrors flag
00476                 ThrowException flag
00477     Purpose:    thread safe wrapper around CCDiskFile
00478 
00479 ********************************************************************************************/
00480 
00481 CCAsynchDiskFile::CCAsynchDiskFile(UINT32 bufferSize,
00482                                     BOOL ErrorReporting, BOOL ExceptionThrowing)
00483         :CCDiskFile( new async_fstream(),bufferSize, ErrorReporting,ExceptionThrowing)
00484 {                      
00485     
00486 }
00487 
00488 
00489 
00490 /********************************************************************************************
00491 
00492                                         CCCAsynchDiskFile
00493 
00494 */
00495 
00496 /********************************************************************************************
00497 
00498 >   CCAsynchDiskFile::CCDiskFile(UINT32 bufferSize,
00499                            BOOL ErrorReporting = TRUE, BOOL ExceptionThrowing = FALSE)
00500 
00501     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00502     Created:    21/08/96
00503     Inputs:     bufferSize  - Size of the fixed size buffer (default = 1024)
00504                             - if size > 0 then create a buffer of the specified size
00505                             - if size = 0 then create a file without a buffer
00506                 ReportErrors flag
00507                 ThrowException flag
00508     Purpose:    thread safe wrapper around CCDiskFile
00509 
00510 ********************************************************************************************/
00511 
00512 CCAsynchDiskFile::CCAsynchDiskFile(PathName fPath, 
00513                                     INT32 fileMode, 
00514                                     INT32 fileAccess,
00515                                     UINT32 bufferSize,
00516                                     BOOL ErrorReporting, 
00517                                     BOOL ExceptionThrowing)
00518         :CCDiskFile(new async_fstream(),
00519                         fPath, 
00520                         fileMode, 
00521                         fileAccess,
00522                         bufferSize,
00523                         ErrorReporting,
00524                         ExceptionThrowing)
00525 {                      
00526 
00527 }
00528 
00529 
00530 
00531 
00532 /********************************************************************************************
00533 
00534 >   CAsynchCDiskFile::~CCAsynchDiskFile()
00535 
00536     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00537     Created:    21/08/96
00538     Purpose:    thread safe wrapper around CCDiskFile
00539 
00540 ********************************************************************************************/
00541 
00542 CCAsynchDiskFile::~CCAsynchDiskFile()
00543 {
00544 
00545 }
00546 
00547 /********************************************************************************************
00548 
00549 >   CCFile& CCAsynchDiskFile::Size()
00550     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00551     Created:    21/08/96
00552     Purpose:    
00553 
00554 ********************************************************************************************/
00555 
00556 INT32 CCAsynchDiskFile::Size()
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 }
00562 
00563 
00564 /********************************************************************************************
00565 
00566 >   BOOL CCAsynchDiskFile::eof() const
00567 
00568     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00569     Created:    3/10/96
00570     Purpose:    Checks eof of the file
00571 
00572 ********************************************************************************************/
00573 
00574 BOOL CCAsynchDiskFile::eof() const
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 }
00585 
00586 
00587 /********************************************************************************************
00588 
00589 >   CCFile::GotError( UNIT errorID )
00590 >   CCFile::GotError( UNIT errorID , const TCHAR*)
00591 
00592     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00593     Created:    29/08/94
00594     Inputs:     Unsigned interger which is the error id and possible error message string
00595     Outputs:    None
00596     Returns:    None
00597     Purpose:    Error handler for the CCFile class. It uses flags set in the constructor
00598                 to determine if the user requires errors to be reported or exceptions
00599                 thrown. 
00600     Errors:     None
00601     SeeAlso:    SetReportErrors; SetThrowExceptions
00602 
00603 ********************************************************************************************/
00604 
00605 void CCAsynchDiskFile::GotError( UINT32 errorID , const TCHAR* errorString)
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 }
00635 
00636 void CCAsynchDiskFile::GotError( UINT32 errorID )
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 }
00685 
00686 
00687 
00688 /********************************************************************************************
00689 
00690 >   void CCAsynchDiskFile::ExitThread(HRESULT Status);
00691     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00692     Created:    21/08/96
00693     Purpose:    call the contained streambuf function to inform it that the download is over
00694 
00695 ********************************************************************************************/
00696 
00697 void CCAsynchDiskFile::DownloadHasEnded(HRESULT Status)
00698 {   
00699     // tell the stream buf that the download is complete
00700     ((asynchstreambuf*)(IOFile->rdbuf()))->DownloadHasEnded(Status);
00701 
00702 }
00703 
00704 
00705 
00706 
00707 /********************************************************************************************
00708 >   async_fstream::async_fstream()
00709 
00710     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00711     Created:    9/9/96
00712 ********************************************************************************************/
00713 
00714 async_fstream::async_fstream()
00715 {
00716     set_streambuf(new asynchstreambuf);
00717 }
00718 
00719 
00720 /********************************************************************************************
00721 >   async_fstream::async_fstream(const char * name, INT32 mode, INT32 prot)
00722 
00723     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00724     Created:    9/9/96
00725 ********************************************************************************************/
00726 
00727 async_fstream::async_fstream(const char * name, INT32 mode, INT32 prot)
00728 {
00729     set_streambuf(new asynchstreambuf);
00730     open(name,mode,prot);
00731 }
00732 
00733 
00734 /********************************************************************************************
00735 >   async_fstream::async_fstream(filedesc fd)
00736 
00737     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00738     Created:    9/9/96
00739 ********************************************************************************************/
00740 
00741 async_fstream::async_fstream(filedesc fd)
00742 {
00743     set_streambuf(new asynchstreambuf);
00744     attach(fd);
00745 }
00746 
00747 
00748 /********************************************************************************************
00749 >   async_fstream::async_fstream(filedesc fd, char * sbuf, INT32 len)
00750 
00751     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00752     Created:    9/9/96
00753 ********************************************************************************************/
00754 
00755 async_fstream::async_fstream(filedesc fd, char * sbuf, INT32 len)
00756 {
00757     set_streambuf(new asynchstreambuf);
00758     setbuf(sbuf, len);
00759     attach(fd);
00760 }
00761 
00762 
00763 /********************************************************************************************
00764 >   async_filebuf* async_fstream::set_streambuf(streambuf* pbuf)
00765 
00766     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00767     Created:    9/9/96
00768 ********************************************************************************************/
00769 
00770 streambuf * async_fstream::set_streambuf(streambuf* pbuf)
00771 {
00772     if (bp) delete bp;
00773     return bp = pbuf;
00774 }

Generated on Sat Nov 10 03:44:38 2007 for Camelot by  doxygen 1.4.4