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.

120 lines
3.4 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: _blobfile.inl
  4. // Copyright (C) 1994-1997 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. //
  8. //
  9. //-----------------------------------------------------------------------------
  10. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  11. // Gets the position with in the file. The position can be set (by calling
  12. // 'Seek()') beyond the end of the data in the file, even beyond the space
  13. // allocated for the file. In any case, 'Read()' and 'Write()' will deal with
  14. // that.
  15. //------------------------------------------------------------------------------
  16. inline
  17. DWORD //Returns current file position
  18. CBlobFile::GetPosition() const
  19. {
  20. ASSERT_VALID(this);
  21. return m_nPosition;
  22. }
  23. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  24. // Gets the actual data size in the file, which is what determines the end
  25. // of file during readings.
  26. //------------------------------------------------------------------------------
  27. inline
  28. DWORD //Returns the file data length in bytes.
  29. CBlobFile::GetLength() const
  30. {
  31. ASSERT_VALID(this);
  32. return m_nFileSize;
  33. }
  34. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  35. // Since we keep the file in memory always, we don't need to flush.
  36. //------------------------------------------------------------------------------
  37. inline
  38. void CBlobFile::Flush()
  39. {
  40. }
  41. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  42. // Aborting is like closing.
  43. //------------------------------------------------------------------------------
  44. inline
  45. void CBlobFile::Abort()
  46. {
  47. ASSERT_VALID(this);
  48. Close();
  49. }
  50. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  51. // Unsupported function
  52. //------------------------------------------------------------------------------
  53. inline
  54. void CBlobFile::LockRange(DWORD /* dwPos */, DWORD /* dwCount */)
  55. {
  56. AfxThrowNotSupportedException();
  57. }
  58. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  59. // Unsupported function
  60. //------------------------------------------------------------------------------
  61. inline
  62. void CBlobFile::UnlockRange(DWORD /* dwPos */, DWORD /* dwCount */)
  63. {
  64. AfxThrowNotSupportedException();
  65. }
  66. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  67. // Unsupported function
  68. //------------------------------------------------------------------------------
  69. inline
  70. CFile* CBlobFile::Duplicate() const
  71. {
  72. AfxThrowNotSupportedException();
  73. return NULL;
  74. }
  75. inline
  76. UINT CBlobFile::GetBlobSize(void) const
  77. {
  78. ASSERT_VALID(this);
  79. return m_blobData.GetBlobSize();
  80. }
  81. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  82. //
  83. // That's the only way to that a caller can have access to the buffer data
  84. // of the blobfile's internal cowblob.
  85. //
  86. //-----------------------------------------------------------------------------
  87. inline
  88. CBlobFile::operator const CLocCOWBlob &(void)
  89. {
  90. return GetBlob();
  91. }
  92. inline
  93. const CLocCOWBlob &
  94. CBlobFile::GetBlob(void)
  95. {
  96. if (m_pBuffer != NULL)
  97. {
  98. m_blobData.ReleasePointer();
  99. m_pBuffer = NULL;
  100. }
  101. //Set correct requested cowblob size before giving access to the data.
  102. m_blobData.ReallocBlob(m_nFileSize);
  103. return m_blobData;
  104. }