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