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.

115 lines
2.6 KiB

  1. // Copyright 1997-1997 Microsoft Corporation. All Rights Reserved.
  2. #ifndef _FS_H_
  3. #define _FS_H_
  4. #if _MSC_VER > 1000
  5. #pragma once
  6. #endif
  7. #include <unknwn.h>
  8. #include "msitstg.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. //
  21. // Sub-File System
  22. //
  23. class CSubFileSystem
  24. {
  25. public:
  26. CSubFileSystem(class CFileSystem* pfs);
  27. ~CSubFileSystem();
  28. HRESULT CreateSub(PCSTR pszPathName);
  29. HRESULT CreateUncompressedSub(PCSTR pszPathName);
  30. HRESULT OpenSub(PCSTR pszPathName, DWORD dwAccess = (STGM_READ | STGM_SHARE_DENY_WRITE));
  31. ULONG WriteSub(const void* pData, int cb);
  32. ULONG SeekSub(int cb, int iOrigin);
  33. HRESULT CreateSystemFile(PCSTR pszPathName);
  34. HRESULT CreateUncompressedSystemFile(PCSTR pszPathName);
  35. HRESULT SetSize(unsigned uSize);
  36. HRESULT DeleteSub() ;
  37. inline HRESULT ReadSub(void* pData, ULONG cb, ULONG* pcbRead) {
  38. return m_pStream->Read(pData, cb, pcbRead);
  39. }
  40. inline ULONG GetUncompressedSize(void) { return SeekSub(0,2); }
  41. inline HRESULT Stat(STATSTG *pstatstg, DWORD grfStatFalg)
  42. {
  43. return m_pStream->Stat(pstatstg,grfStatFalg);
  44. }
  45. inline HRESULT CopyTo(IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER* pcbWritten)
  46. {
  47. return m_pStream->CopyTo(pstm, cb, pcbRead, pcbWritten);
  48. }
  49. inline IStream * GetStream(void)
  50. {
  51. return m_pStream;
  52. }
  53. inline IStorage* GetITStorageDocObj(void) const
  54. {
  55. return m_pStorage;
  56. }
  57. private:
  58. class CFileSystem* m_pFS;
  59. IStorage* m_pStorage;
  60. IStream* m_pStream;
  61. char m_szPathName[MAX_PATH]; // Needed for delete.
  62. };
  63. //
  64. // File System
  65. //
  66. class CFileSystem
  67. {
  68. friend class CSubFileSystem;
  69. public:
  70. CFileSystem();
  71. ~CFileSystem();
  72. HRESULT Init(void);
  73. HRESULT Create( PCSTR pszPathName );
  74. HRESULT CreateUncompressed( PCSTR pszPathName );
  75. HRESULT Open( PCSTR pszPathName, DWORD dwAccess = (STGM_READ | STGM_SHARE_DENY_WRITE));
  76. HRESULT Compact(LPCSTR lpszFileName);
  77. HRESULT Close(void);
  78. inline HRESULT GetPathName( LPSTR pszPathName ) { strcpy(pszPathName, m_szPathName); return S_OK; }
  79. inline IITStorage* GetITStorageObj(void) const
  80. {
  81. return m_pITStorage;
  82. }
  83. inline IStorage* GetITStorageDocObj(void) const
  84. {
  85. return m_pStorage;
  86. }
  87. private:
  88. IITStorage* m_pITStorage;
  89. IStorage* m_pStorage;
  90. char m_szPathName[MAX_PATH];
  91. };
  92. #endif // _FS_H_