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.

188 lines
3.2 KiB

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