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.

131 lines
3.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: docname.hxx
  7. //
  8. // Contents: Storage Client for document
  9. //
  10. // History: 11-22-96 srikants Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #pragma once
  14. #include <ciintf.h>
  15. #include <cifrmcom.hxx>
  16. //+---------------------------------------------------------------------------
  17. //
  18. // Class: CCiCDocName
  19. //
  20. // Purpose: Storage system's notion of a document name. It is a NULL terminated
  21. // wide char full path to the file.
  22. //
  23. // History: 11-22-96 srikants Created
  24. //
  25. // Notes: This class is NOT multi-thread safe. The user must make sure
  26. // that only one thread is using it at a time.
  27. //
  28. //----------------------------------------------------------------------------
  29. class CCiCDocName : public ICiCDocName
  30. {
  31. public:
  32. //
  33. // Constructor and Destructor
  34. //
  35. CCiCDocName( WCHAR const * pwszPath = 0 );
  36. CCiCDocName( WCHAR const * pwszPath, ULONG cwc );
  37. //
  38. // IUnknown methods.
  39. //
  40. STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID *ppiuk );
  41. STDMETHOD_(ULONG, AddRef) (THIS);
  42. STDMETHOD_(ULONG, Release) (THIS);
  43. //
  44. // ICiCDocName methods.
  45. //
  46. STDMETHOD(Init) ( const BYTE * pbData, ULONG cbData );
  47. STDMETHOD(Set) ( const ICiCDocName * pICiCDocName );
  48. STDMETHOD(Clear) (void);
  49. STDMETHOD(IsValid) (void);
  50. STDMETHOD(Duplicate) ( ICiCDocName ** ppICiCDocName );
  51. STDMETHOD(Get) ( BYTE * pbName, ULONG * pcbName ) ;
  52. STDMETHOD(GetNameBuffer) ( BYTE const * * ppbName, ULONG * pcbName );
  53. STDMETHOD(GetBufSizeNeeded) ( ULONG * pcbName );
  54. //
  55. // Methods specific to CCiCDocName.
  56. //
  57. WCHAR const * GetPath() const
  58. {
  59. return _pwszPath;
  60. }
  61. void SetPath( WCHAR const * pwszPath, ULONG cwc );
  62. static BOOL IsEvenNumber( ULONG n )
  63. {
  64. return 0 == (n & 0x1);
  65. }
  66. protected:
  67. virtual ~CCiCDocName()
  68. {
  69. Win4Assert( 0 == _refCount );
  70. FreeResources();
  71. }
  72. private:
  73. enum { CWC_DELTA = 32 };
  74. void FreeResources()
  75. {
  76. if ( 0 != _pwszPath && _wszBuffer != _pwszPath )
  77. {
  78. delete [] _pwszPath;
  79. _pwszPath = 0;
  80. _cwcMax = _cwcPath = 0;
  81. }
  82. }
  83. ULONG ComputeBufSize() const
  84. {
  85. return (_cwcPath+1) * sizeof(WCHAR);
  86. }
  87. WCHAR * _pwszPath; // Actual path
  88. LONG _refCount; // Refcounting
  89. BOOL _fIsInit; // Is it initialized ??
  90. ULONG _cwcMax; // Maximum number of chars in _pwszPath
  91. ULONG _cwcPath; // Number of characters in the path
  92. WCHAR _wszBuffer[MAX_PATH]; // used for default path name
  93. };