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.

88 lines
2.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1996, Microsoft Corporation.
  4. //
  5. // File: fmapio.hxx
  6. //
  7. // Contents: Parser for an HTX file
  8. //
  9. // History: 96/Jan/3 DwightKr Created
  10. // Aug 20 1996 Srikants Moved from htx.hxx to this file
  11. //
  12. //----------------------------------------------------------------------------
  13. #pragma once
  14. #include <tgrow.hxx>
  15. //+---------------------------------------------------------------------------
  16. //
  17. // Class: CFileMapView
  18. //
  19. // Purpose: Maps a file in its entirity
  20. //
  21. // History: 96/Jan/23 DwightKr Created
  22. //
  23. //----------------------------------------------------------------------------
  24. class CFileMapView : INHERIT_UNWIND
  25. {
  26. INLINE_UNWIND(CFileMapView)
  27. public:
  28. CFileMapView( WCHAR const * wcsFileName );
  29. ~CFileMapView();
  30. void Init();
  31. HANDLE GetFileHandle() const { return _hFile; }
  32. BYTE * GetBuffer() const { return _pbBuffer; }
  33. ULONG GetBufferSize() const { return _cbBuffer; }
  34. BYTE operator[](unsigned i)
  35. {
  36. Win4Assert( i < _cbBuffer );
  37. return _pbBuffer[i];
  38. }
  39. BOOL IsUnicode() const { return _IsUnicode; }
  40. private:
  41. HANDLE _hFile; // Handle to the file
  42. HANDLE _hMap; // Handle to the map
  43. BYTE * _pbBuffer; // Pointer to the allocated memory
  44. ULONG _cbBuffer; // Size of the mapped file
  45. BOOL _IsUnicode; // Does this file contain unicode?
  46. };
  47. //+---------------------------------------------------------------------------
  48. //
  49. // Class: CFileBuffer
  50. //
  51. // Purpose: Manages a UNICODE representation of a mapped file
  52. //
  53. // History: 96/May/06 DwightKr Created
  54. //
  55. //----------------------------------------------------------------------------
  56. class CFileBuffer : INHERIT_UNWIND
  57. {
  58. INLINE_UNWIND(CFileBuffer);
  59. public:
  60. CFileBuffer( CFileMapView & fileMap,
  61. UINT codePage );
  62. ULONG fgetsw( XGrowable<WCHAR> & xLine );
  63. private:
  64. WCHAR * _wcsNextLine;
  65. ULONG _cwcFileBuffer;
  66. XArray<WCHAR> _pwBuffer;
  67. };