PVRTResourceFile.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /******************************************************************************
  2. @File PVRTResourceFile.h
  3. @Title PVRTResourceFile
  4. @Version
  5. @Copyright Copyright (C) Imagination Technologies Limited.
  6. @Platform ANSI compatible
  7. @Description Simple resource file wrapper
  8. ******************************************************************************/
  9. #ifndef _PVRTRESOURCEFILE_H_
  10. #define _PVRTRESOURCEFILE_H_
  11. #include <stdlib.h>
  12. #include "PVRTString.h"
  13. /*!***************************************************************************
  14. @Class CPVRTResourceFile
  15. @Brief Simple resource file wrapper
  16. *****************************************************************************/
  17. class CPVRTResourceFile
  18. {
  19. public:
  20. /*!***************************************************************************
  21. @Function SetReadPath
  22. @Input pszReadPath The path where you would like to read from
  23. @Description Sets the read path
  24. *****************************************************************************/
  25. static void SetReadPath(const char* pszReadPath);
  26. /*!***************************************************************************
  27. @Function GetReadPath
  28. @Returns The currently set read path
  29. @Description Returns the currently set read path
  30. *****************************************************************************/
  31. static CPVRTString GetReadPath();
  32. /*!***************************************************************************
  33. @Function CPVRTResourceFile
  34. @Input pszFilename Name of the file you would like to open
  35. @Description Constructor
  36. *****************************************************************************/
  37. CPVRTResourceFile(const char* pszFilename);
  38. /*!***************************************************************************
  39. @Function CPVRTResourceFile
  40. @Input pData A pointer to the data you would like to use
  41. @Input i32Size The size of the data
  42. @Description Constructor
  43. *****************************************************************************/
  44. CPVRTResourceFile(const char* pData, size_t i32Size);
  45. /*!***************************************************************************
  46. @Function ~CPVRTResourceFile
  47. @Description Destructor
  48. *****************************************************************************/
  49. virtual ~CPVRTResourceFile();
  50. /*!***************************************************************************
  51. @Function IsOpen
  52. @Returns true if the file is open
  53. @Description Is the file open
  54. *****************************************************************************/
  55. bool IsOpen() const;
  56. /*!***************************************************************************
  57. @Function IsMemoryFile
  58. @Returns true if the file was opened from memory
  59. @Description Was the file opened from memory
  60. *****************************************************************************/
  61. bool IsMemoryFile() const;
  62. /*!***************************************************************************
  63. @Function Size
  64. @Returns The size of the opened file
  65. @Description Returns the size of the opened file
  66. *****************************************************************************/
  67. size_t Size() const;
  68. /*!***************************************************************************
  69. @Function DataPtr
  70. @Returns A pointer to the file data
  71. @Description Returns a pointer to the file data
  72. *****************************************************************************/
  73. const void* DataPtr() const;
  74. /*!***************************************************************************
  75. @Function StringPtr
  76. @Returns The file data as a string
  77. @Description Returns the file as a null-terminated string
  78. *****************************************************************************/
  79. // convenience getter. Also makes it clear that you get a null-terminated buffer.
  80. const char* StringPtr() const;
  81. /*!***************************************************************************
  82. @Function Close
  83. @Description Closes the file
  84. *****************************************************************************/
  85. void Close();
  86. protected:
  87. bool m_bOpen;
  88. bool m_bMemoryFile;
  89. size_t m_Size;
  90. const char* m_pData;
  91. static CPVRTString s_ReadPath;
  92. };
  93. #endif // _PVRTRESOURCEFILE_H_
  94. /*****************************************************************************
  95. End of file (PVRTResourceFile.h)
  96. *****************************************************************************/