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.

190 lines
3.2 KiB

  1. /*++
  2. Copyright (C) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. CLFILE.INL
  5. History:
  6. --*/
  7. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  8. //
  9. // Constructor for the CLFile object - we create the CFile
  10. //
  11. //-----------------------------------------------------------------------------
  12. inline
  13. CLFile::CLFile()
  14. {
  15. m_pFile = new CFile();
  16. m_bDeleteFile = TRUE;
  17. }
  18. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  19. //
  20. // Constructor for the CLFile object - user provides a CFile. User is
  21. // responsible for the CFile object!
  22. //
  23. //-----------------------------------------------------------------------------
  24. inline
  25. CLFile::CLFile(
  26. CFile *pFile)
  27. {
  28. LTASSERT(pFile != NULL);
  29. m_pFile = pFile;
  30. m_bDeleteFile = FALSE;
  31. }
  32. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  33. //
  34. // Destructor - also delete contained CFile if not user supplied.
  35. //
  36. //-----------------------------------------------------------------------------
  37. inline
  38. CLFile::~CLFile()
  39. {
  40. DEBUGONLY(AssertValid());
  41. if (m_bDeleteFile)
  42. {
  43. delete m_pFile;
  44. }
  45. }
  46. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  47. //
  48. // Read a byte at the current file position
  49. //
  50. //-----------------------------------------------------------------------------
  51. inline
  52. UINT //Byte count read
  53. CLFile::ReadByte(
  54. BYTE & byte) //where to place the byte
  55. {
  56. if (Read(&byte, sizeof(BYTE)) != sizeof(BYTE))
  57. {
  58. AfxThrowFileException(CFileException::endOfFile);
  59. }
  60. return sizeof(BYTE);
  61. }
  62. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  63. //
  64. // Write a byte at the current file position
  65. //
  66. //-----------------------------------------------------------------------------
  67. inline
  68. UINT //Byte count written
  69. CLFile::WriteByte(
  70. const BYTE & byte)
  71. {
  72. Write(&byte, sizeof(BYTE));
  73. return sizeof(BYTE);
  74. }
  75. //-----------------------------------------------------------------------------
  76. // The following are the CFile methods that are reimplemented
  77. //-----------------------------------------------------------------------------
  78. inline
  79. DWORD
  80. CLFile::GetPosition()
  81. const
  82. {
  83. return m_pFile->GetPosition();
  84. }
  85. inline
  86. DWORD
  87. CLFile::SeekToEnd()
  88. {
  89. return m_pFile->SeekToEnd();
  90. }
  91. inline
  92. void
  93. CLFile::SeekToBegin()
  94. {
  95. m_pFile->SeekToBegin();
  96. }
  97. inline
  98. LONG
  99. CLFile::Seek(
  100. LONG lOff,
  101. UINT nFrom)
  102. {
  103. return m_pFile->Seek(lOff, nFrom);
  104. }
  105. inline
  106. void
  107. CLFile::SetLength(
  108. DWORD dwNewLen)
  109. {
  110. m_pFile->SetLength(dwNewLen);
  111. }
  112. inline
  113. DWORD
  114. CLFile::GetLength()
  115. const
  116. {
  117. return m_pFile->GetLength();
  118. }
  119. inline
  120. UINT
  121. CLFile::Read(
  122. void* lpBuf,
  123. UINT nCount)
  124. {
  125. return m_pFile->Read(lpBuf, nCount);
  126. }
  127. inline
  128. void
  129. CLFile::Write(
  130. const void* lpBuf,
  131. UINT nCount)
  132. {
  133. m_pFile->Write(lpBuf, nCount);
  134. }
  135. inline
  136. void
  137. CLFile::Flush()
  138. {
  139. m_pFile->Flush();
  140. }
  141. inline
  142. void
  143. CLFile::Close()
  144. {
  145. m_pFile->Close();
  146. }
  147. inline
  148. void
  149. CLFile::Abort()
  150. {
  151. m_pFile->Abort();
  152. }
  153. inline
  154. CLString
  155. CLFile::GetFileName(void)
  156. const
  157. {
  158. return m_pFile->GetFileName();
  159. }