Leaked source code of windows server 2003
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.

114 lines
3.1 KiB

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