IReadFile.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef IRR_I_READ_FILE_H_INCLUDED
  5. #define IRR_I_READ_FILE_H_INCLUDED
  6. #include "IReferenceCounted.h"
  7. #include "coreutil.h"
  8. #include "EReadFileType.h"
  9. namespace irr
  10. {
  11. namespace io
  12. {
  13. //! Interface providing read access to a file.
  14. class IReadFile : public virtual IReferenceCounted
  15. {
  16. public:
  17. //! Reads an amount of bytes from the file.
  18. /** \param buffer Pointer to buffer where read bytes are written to.
  19. \param sizeToRead Amount of bytes to read from the file.
  20. \return How many bytes were read. */
  21. virtual size_t read(void* buffer, size_t sizeToRead) = 0;
  22. //! Changes position in file
  23. /** \param finalPos Destination position in the file.
  24. \param relativeMovement If set to true, the position in the file is
  25. changed relative to current position. Otherwise the position is changed
  26. from beginning of file.
  27. \return True if successful, otherwise false. */
  28. virtual bool seek(long finalPos, bool relativeMovement = false) = 0;
  29. //! Get size of file.
  30. /** \return Size of the file in bytes. */
  31. virtual long getSize() const = 0;
  32. //! Get the current position in the file.
  33. /** \return Current position in the file in bytes on success or -1L on failure. */
  34. virtual long getPos() const = 0;
  35. //! Get name of file.
  36. /** \return File name as zero terminated character string. */
  37. virtual const io::path& getFileName() const = 0;
  38. //! Get the type of the class implementing this interface
  39. virtual EREAD_FILE_TYPE getType() const
  40. {
  41. return EFIT_UNKNOWN;
  42. }
  43. };
  44. //! Internal function, please do not use.
  45. IReadFile* createLimitReadFile(const io::path& fileName, IReadFile* alreadyOpenedFile, long pos, long areaSize);
  46. } // end namespace io
  47. } // end namespace irr
  48. #endif