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.

160 lines
4.6 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: clfile.h
  4. // Copyright (C) 1994-1997 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // Wrapper class for CFile. It allows us to use CPascalString for
  8. // file names, and does some 'text mode' read/write operations.
  9. // This class contains a pointer to a CFile but contains most of
  10. // the CFile methods thus it can be used as a CFile. CLFile will either
  11. // use an existing CFile provided at construction time or it will create its
  12. // own CFile as needed. In either case, the enbeded CFile is destroyed when
  13. // the CLFile is destroyed.
  14. //
  15. //-----------------------------------------------------------------------------
  16. #ifndef CLFILE_H
  17. #define CLFILE_H
  18. #pragma warning(disable : 4275)
  19. class LTAPIENTRY CLFile : public CObject
  20. {
  21. public:
  22. CLFile();
  23. CLFile(CFile *);
  24. ~CLFile();
  25. void AssertValid(void) const;
  26. //-----------------------------------------------------------------------------
  27. // The following are the CFile methods that are reimplemented
  28. //-----------------------------------------------------------------------------
  29. DWORD GetPosition() const;
  30. DWORD SeekToEnd();
  31. void SeekToBegin();
  32. LONG Seek(LONG lOff, UINT nFrom);
  33. void SetLength(DWORD dwNewLen);
  34. DWORD GetLength() const;
  35. UINT Read(void* lpBuf, UINT nCount);
  36. void Write(const void* lpBuf, UINT nCount);
  37. void LockRange(DWORD dwPos, DWORD dwCount);
  38. void UnlockRange(DWORD dwPos, DWORD dwCount);
  39. void Abort();
  40. void Flush();
  41. void Close();
  42. CLString GetFileName(void) const;
  43. //-----------------------------------------------------------------------------
  44. // The following are all the CLFile methods
  45. //-----------------------------------------------------------------------------
  46. BOOL Open(const CPascalString &pstrFileName, UINT nOpenFlags,
  47. CFileException *pError = NULL);
  48. static void Rename(const CPascalString &pstrFileName,
  49. const CPascalString &pstrNewName);
  50. static void Remove(const CPascalString &pstrFileName);
  51. static void CopyFile(
  52. const CPascalString &pasSource,
  53. const CPascalString &pasTarget,
  54. BOOL fFailIfExist = TRUE,
  55. CProgressiveObject *pProgress = NULL);
  56. static BOOL GetStatus(const CPascalString &pstrFileName,
  57. CFileStatus &rStatus);
  58. static void SetStatus(const CPascalString &pstrFileName,
  59. const CFileStatus &status);
  60. UINT ReadLine(CPascalString &pstrLine, CodePage cp);
  61. UINT ReadLine(CPascalString &pstrLine);
  62. UINT ReadString(CPascalString &pstrLine, CodePage cp);
  63. UINT ReadString(CPascalString &pstrLine);
  64. UINT ReadByte(BYTE &);
  65. UINT ReadWord(WORD &, BOOL BigEnded = FALSE);
  66. UINT ReadDWord(DWORD &, BOOL BigEnded = FALSE);
  67. UINT ReadPascalB(CPascalString &);
  68. UINT ReadPascalW(CPascalString &);
  69. UINT ReadPascalD(CPascalString &);
  70. UINT ReadPascalB(CPascalString &, CodePage);
  71. UINT ReadPascalW(CPascalString &, CodePage);
  72. UINT ReadPascalD(CPascalString &, CodePage);
  73. UINT Read(CPascalString &pstr, UINT nCount, CodePage cp);
  74. UINT Read(CPascalString &pstr, UINT nCount);
  75. UINT WriteLine(const CPascalString &pstrLine, CodePage cp);
  76. UINT WriteLine(const CPascalString &pstrLine);
  77. UINT WriteString(const CPascalString &pstrString, CodePage cp);
  78. UINT WriteString(const CPascalString &pstrString);
  79. UINT WriteByte(const BYTE &);
  80. UINT WriteWord(const WORD &, BOOL BigEnded = FALSE);
  81. UINT WriteDWord(const DWORD &, BOOL BigEnded = FALSE);
  82. UINT WritePascalB(const CPascalString &);
  83. UINT WritePascalW(const CPascalString &);
  84. UINT WritePascalD(const CPascalString &);
  85. UINT WritePascalB(const CPascalString &, CodePage);
  86. UINT WritePascalW(const CPascalString &, CodePage);
  87. UINT WritePascalD(const CPascalString &, CodePage);
  88. UINT Write(const CPascalString &pstrString);
  89. UINT Write(const CPascalString &pstrString, CodePage cp);
  90. UINT SkipToBoundary(UINT nBoundary);
  91. UINT PadToBoundary(UINT nBoundary, BYTE ucPad = 0);
  92. void Pad(UINT nCount, BYTE ucPad = 0);
  93. UINT CopyRange(CLFile &Target, UINT uiNumBytes,
  94. CProgressiveObject *pProgress = NULL);
  95. protected:
  96. CFile *m_pFile;
  97. BOOL m_bDeleteFile; //Should we delete m_pFile in our destructor?
  98. };
  99. enum FileStat
  100. {
  101. fsNoStatus = 0x00,
  102. fsNotFound = 0x01,
  103. fsUpToDate = 0x02,
  104. fsFileNewer = 0x04,
  105. fsFileOlder = 0x08,
  106. fsNotReadable = 0x10,
  107. fsNotWritable = 0x20
  108. };
  109. WORD
  110. LTAPIENTRY LocateFile(
  111. const CLString &strFileName,
  112. const COleDateTime &tGmtFileTime);
  113. #pragma warning(default : 4275)
  114. #if !defined(_DEBUG) || defined(IMPLEMENT)
  115. #include "clfile.inl"
  116. #endif
  117. #endif // CLFILE_H