CReadFile.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 __C_READ_FILE_H_INCLUDED__
  5. #define __C_READ_FILE_H_INCLUDED__
  6. #include <stdio.h>
  7. #include "IReadFile.h"
  8. #include "irrString.h"
  9. namespace irr
  10. {
  11. namespace io
  12. {
  13. /*!
  14. Class for reading a real file from disk.
  15. */
  16. class CReadFile : public IReadFile
  17. {
  18. public:
  19. CReadFile(const io::path& fileName);
  20. virtual ~CReadFile();
  21. //! returns how much was read
  22. virtual s32 read(void* buffer, u32 sizeToRead);
  23. //! changes position in file, returns true if successful
  24. virtual bool seek(long finalPos, bool relativeMovement = false);
  25. //! returns size of file
  26. virtual long getSize() const;
  27. //! returns if file is open
  28. virtual bool isOpen() const
  29. {
  30. return File != 0;
  31. }
  32. //! returns where in the file we are.
  33. virtual long getPos() const;
  34. //! returns name of file
  35. virtual const io::path& getFileName() const;
  36. private:
  37. //! opens the file
  38. void openFile();
  39. FILE* File;
  40. long FileSize;
  41. io::path Filename;
  42. };
  43. } // end namespace io
  44. } // end namespace irr
  45. #endif