home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / src / arcstrm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  3.7 KB  |  183 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef AFX_CMNCTL_SEG
  14. #pragma code_seg(AFX_CMNCTL_SEG)
  15. #endif
  16.  
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21.  
  22. #define new DEBUG_NEW
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CArchiveStream
  26.  
  27. #ifndef _AFX_NO_OLE_SUPPORT
  28. #if defined(_WIN32_WCE)
  29. // private definitions of IIDs to avoid linking with uuid.lib
  30. static const IID IID_IUnknown =
  31.     { 0x00000000, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } };
  32. static const IID IID_IStream =
  33.     { 0x0000000C, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } };
  34. #endif // _WIN32_WCE
  35.  
  36. CArchiveStream::CArchiveStream(CArchive* pArchive)
  37. {
  38.     m_pArchive = pArchive;
  39. }
  40.  
  41. STDMETHODIMP_(ULONG)CArchiveStream::AddRef()
  42. {
  43.     return 1;
  44. }
  45.  
  46. STDMETHODIMP_(ULONG)CArchiveStream::Release()
  47. {
  48.     return 0;
  49. }
  50.  
  51. STDMETHODIMP CArchiveStream::QueryInterface(REFIID iid, LPVOID* ppvObj)
  52. {
  53.     if (iid == IID_IUnknown || iid == IID_IStream)
  54.     {
  55.         *ppvObj = this;
  56.         return NOERROR;
  57.     }
  58.     return E_NOINTERFACE;
  59. }
  60.  
  61. STDMETHODIMP CArchiveStream::Read(void *pv, ULONG cb, ULONG *pcbRead)
  62. {
  63.     ASSERT(m_pArchive != NULL);
  64.     ASSERT(m_pArchive->IsLoading());
  65.  
  66.     int nRead = 0;
  67.     TRY
  68.     {
  69.         nRead = m_pArchive->Read(pv, cb);
  70.     }
  71.     CATCH_ALL(e)
  72.     {
  73.         DELETE_EXCEPTION(e);
  74.         return E_UNEXPECTED;
  75.     }
  76.     END_CATCH_ALL
  77.  
  78.     if (pcbRead != NULL)
  79.         *pcbRead = nRead;
  80.     return NOERROR;
  81. }
  82.  
  83. STDMETHODIMP CArchiveStream::Write(const void *pv, ULONG cb, ULONG *pcbWritten)
  84. {
  85.     ASSERT(m_pArchive != NULL);
  86.     ASSERT(m_pArchive->IsStoring());
  87.  
  88.     int nWrite = 0;
  89.     TRY
  90.     {
  91.         m_pArchive->Write(pv, cb);
  92.         nWrite = cb;
  93.     }
  94.     CATCH_ALL(e)
  95.     {
  96.         DELETE_EXCEPTION(e);
  97.         return E_UNEXPECTED;
  98.     }
  99.     END_CATCH_ALL
  100.  
  101.     if (pcbWritten != NULL)
  102.         *pcbWritten = nWrite;
  103.     return NOERROR;
  104. }
  105.  
  106. STDMETHODIMP CArchiveStream::Seek(LARGE_INTEGER uliOffset, DWORD dwOrigin,
  107.     ULARGE_INTEGER* puliNew)
  108. {
  109.     // can't handle offsets with really large magnitude
  110.     if ((uliOffset.HighPart != 0) &&
  111.         ((uliOffset.HighPart != -1) || ((long)uliOffset.LowPart >= 0)))
  112.         return E_NOTIMPL;
  113.  
  114.     CFile* pFile = m_pArchive->GetFile();
  115.     if (pFile == NULL)
  116.         return E_NOTIMPL;
  117.     m_pArchive->Flush();
  118.  
  119.     ASSERT(STREAM_SEEK_SET == CFile::begin);
  120.     ASSERT(STREAM_SEEK_CUR == CFile::current);
  121.     ASSERT(STREAM_SEEK_END == CFile::end);
  122.     LONG lNew;
  123.     TRY
  124.     {
  125.         lNew = pFile->Seek((LONG)uliOffset.LowPart, (UINT)dwOrigin);
  126.     }
  127.     CATCH_ALL(e)
  128.     {
  129.         DELETE_EXCEPTION(e);
  130.         return E_UNEXPECTED;
  131.     }
  132.     END_CATCH_ALL
  133.  
  134.     if (puliNew != NULL)
  135.         ULISet32(*puliNew, lNew);
  136.  
  137.     return NOERROR;
  138. }
  139.  
  140. STDMETHODIMP CArchiveStream::SetSize(ULARGE_INTEGER)
  141. {
  142.     return E_NOTIMPL;
  143. }
  144.  
  145. STDMETHODIMP CArchiveStream::CopyTo(LPSTREAM, ULARGE_INTEGER, ULARGE_INTEGER*,
  146.     ULARGE_INTEGER*)
  147. {
  148.     return E_NOTIMPL;
  149. }
  150.  
  151. STDMETHODIMP CArchiveStream::Commit(DWORD)
  152. {
  153.     return E_NOTIMPL;
  154. }
  155.  
  156. STDMETHODIMP CArchiveStream::Revert()
  157. {
  158.     return E_NOTIMPL;
  159. }
  160.  
  161. STDMETHODIMP CArchiveStream::LockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD)
  162. {
  163.     return E_NOTIMPL;
  164. }
  165.  
  166. STDMETHODIMP CArchiveStream::UnlockRegion(ULARGE_INTEGER, ULARGE_INTEGER,
  167.     DWORD)
  168. {
  169.     return E_NOTIMPL;
  170. }
  171.  
  172. STDMETHODIMP CArchiveStream::Stat(STATSTG*, DWORD)
  173. {
  174.     return E_NOTIMPL;
  175. }
  176.  
  177. STDMETHODIMP CArchiveStream::Clone(LPSTREAM*)
  178. {
  179.     return E_NOTIMPL;
  180. }
  181.  
  182. #endif // _AFX_NO_OLE_SUPPORT
  183.