CWriteFile.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_WRITE_FILE_H_INCLUDED__
  5. #define __C_WRITE_FILE_H_INCLUDED__
  6. #include <stdio.h>
  7. #include "IWriteFile.h"
  8. #include "irrString.h"
  9. namespace irr
  10. {
  11. namespace io
  12. {
  13. /*!
  14. Class for writing a real file to disk.
  15. */
  16. class CWriteFile : public IWriteFile
  17. {
  18. public:
  19. CWriteFile(const io::path& fileName, bool append);
  20. virtual ~CWriteFile();
  21. //! Reads an amount of bytes from the file.
  22. virtual s32 write(const void* buffer, u32 sizeToWrite);
  23. //! Changes position in file, returns true if successful.
  24. virtual bool seek(long finalPos, bool relativeMovement = false);
  25. //! Returns the current position in the file.
  26. virtual long getPos() const;
  27. //! Returns name of file.
  28. virtual const io::path& getFileName() const;
  29. //! returns if file is open
  30. bool isOpen() const;
  31. private:
  32. //! opens the file
  33. void openFile(bool append);
  34. io::path Filename;
  35. FILE* File;
  36. long FileSize;
  37. };
  38. } // end namespace io
  39. } // end namespace irr
  40. #endif