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
7 #include "IMemoryReadFile.h"
8 #include "IWriteFile.h"
18 Class for reading from memory.
20 class CMemoryReadFile final
: public IMemoryReadFile
24 CMemoryReadFile(const void *memory
, long len
, const io::path
&fileName
, bool deleteMemoryWhenDropped
);
27 virtual ~CMemoryReadFile();
29 //! returns how much was read
30 size_t read(void *buffer
, size_t sizeToRead
) override
;
32 //! changes position in file, returns true if successful
33 bool seek(long finalPos
, bool relativeMovement
= false) override
;
35 //! returns size of file
36 long getSize() const override
;
38 //! returns where in the file we are.
39 long getPos() const override
;
41 //! returns name of file
42 const io::path
&getFileName() const override
;
44 //! Get the type of the class implementing this interface
45 EREAD_FILE_TYPE
getType() const override
47 return ERFT_MEMORY_READ_FILE
;
50 //! Get direct access to internal buffer
51 const void *getBuffer() const override
61 bool deleteMemoryWhenDropped
;
65 Class for writing to memory.
67 class CMemoryWriteFile
: public IWriteFile
71 CMemoryWriteFile(void *memory
, long len
, const io::path
&fileName
, bool deleteMemoryWhenDropped
);
74 virtual ~CMemoryWriteFile();
76 //! returns how much was written
77 size_t write(const void *buffer
, size_t sizeToWrite
) override
;
79 //! changes position in file, returns true if successful
80 bool seek(long finalPos
, bool relativeMovement
= false) override
;
82 //! returns where in the file we are.
83 long getPos() const override
;
85 //! returns name of file
86 const io::path
&getFileName() const override
;
88 bool flush() override
;
95 bool deleteMemoryWhenDropped
;
99 } // end namespace irr