2
0

IReadFile.h 1.7 KB

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