Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.6 KiB

  1. // Copyright 1997 Microsoft Corporation. All Rights Reserved.
  2. #if _MSC_VER > 1000
  3. #pragma once
  4. #endif
  5. #ifndef _FSCLIENT_H_
  6. #define _FSCLIENT_H_
  7. //#include "msitstg.h"
  8. #include "fs.h"
  9. #ifdef ReleaseObjPtr
  10. #undef ReleaseObjPtr
  11. #endif
  12. #define ReleaseObjPtr(pObj) \
  13. { \
  14. if( pObj ) \
  15. { \
  16. pObj->Release(); \
  17. pObj= NULL; \
  18. } \
  19. }
  20. class CFSClient
  21. {
  22. public:
  23. CFSClient();
  24. CFSClient(CFileSystem* pFS, PCSTR pszSubFile);
  25. ~CFSClient();
  26. BOOL Initialize(PCSTR pszCompiledFile);
  27. void Initialize(CFileSystem* pFS) { m_pFS = pFS; m_fNoDeleteFS = TRUE; }
  28. HRESULT OpenStream(PCSTR pszFile, DWORD dwAccess = STGM_READ);
  29. BOOL isStreamOpen() { return m_pSubFS != NULL; }
  30. // ********** Internal stream functions **********
  31. HRESULT Read(void* pDst, const ULONG cbRead, ULONG* pcbRead);
  32. ULONG Read(PBYTE pbDest, ULONG cbBytes); // stream read
  33. HRESULT doRead(void* pbDst, ULONG cbBytes) {
  34. if (Read((PBYTE) pbDst, cbBytes) == cbBytes)
  35. return S_OK;
  36. else
  37. return STG_E_READFAULT;
  38. }
  39. int tell(void) const { return m_lFileBuf + (int)(m_pCurBuf - m_pbuf); };
  40. HRESULT seek(int pos, SEEK_TYPE seek = SK_SET);
  41. // ********** End Internal stream functions **********
  42. void CloseStream(void);
  43. ULONG GetElementStat() { return GetElementStat(1, &m_Stat); }
  44. ULONG GetElementStat(IEnumSTATSTG* pEnum, STATSTG* pStat) { return GetElementStat(1, pStat, pEnum); }
  45. ULONG GetElementStat(ULONG nNumber, STATSTG* stat, IEnumSTATSTG* pEnum = NULL);
  46. LPWSTR GetStatName() const { return m_Stat.pwcsName; }
  47. DWORD GetStatType() const { return m_Stat.type; }
  48. void WriteStorageContents(PCSTR pszRootFolder, OLECHAR* wszFSName);
  49. // void WaitForReadAhead(void);
  50. void ReadBuf(void);
  51. ULONG SeekSub(int cb, int iOrigin) {
  52. ASSERT(m_pSubFS);
  53. return m_pSubFS->SeekSub(cb, iOrigin); }
  54. STATSTG m_Stat;
  55. IEnumSTATSTG* m_pEnum;
  56. CFileSystem* m_pFS;
  57. CSubFileSystem* m_pSubFS;
  58. PBYTE m_pCurBuf; // current position in the buffer
  59. PBYTE m_pEndBuf; // last position in buffer
  60. BOOL m_fEndOfFile;
  61. int m_lFilePos; // position in the file
  62. int m_lFileBuf; // file position at first of buffer
  63. PBYTE m_pbuf; // address of allocated buffer
  64. int m_cbBuf; // buffer size
  65. int m_cThrdRead; // result from read-ahead thread
  66. HANDLE m_hthrd;
  67. DWORD m_idThrd;
  68. BOOL m_fDualCPU;
  69. BOOL m_fNoDeleteFS;
  70. };
  71. #endif // _FSCLIENT_H_