2011-01-14 05:24:40 -08:00
|
|
|
// Copyright (C) 2002-2011 Nikolaus Gebhardt
|
2007-05-20 11:03:49 -07:00
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#ifndef __C_MEMORY_READ_FILE_H_INCLUDED__
|
|
|
|
#define __C_MEMORY_READ_FILE_H_INCLUDED__
|
|
|
|
|
|
|
|
#include "IReadFile.h"
|
2009-01-16 06:19:38 -08:00
|
|
|
#include "IWriteFile.h"
|
2007-05-20 11:03:49 -07:00
|
|
|
#include "irrString.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace io
|
|
|
|
{
|
|
|
|
|
|
|
|
/*!
|
2009-01-16 06:19:38 -08:00
|
|
|
Class for reading and writing from memory.
|
2007-05-20 11:03:49 -07:00
|
|
|
*/
|
2009-01-16 06:19:38 -08:00
|
|
|
class CMemoryFile : public IReadFile, public IWriteFile
|
2007-05-20 11:03:49 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2008-07-17 02:07:21 -07:00
|
|
|
//! Constructor
|
2009-08-24 02:12:27 -07:00
|
|
|
CMemoryFile(void* memory, long len, const io::path& fileName, bool deleteMemoryWhenDropped);
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2008-07-17 02:07:21 -07:00
|
|
|
//! Destructor
|
2009-01-16 06:19:38 -08:00
|
|
|
virtual ~CMemoryFile();
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! returns how much was read
|
|
|
|
virtual s32 read(void* buffer, u32 sizeToRead);
|
|
|
|
|
2009-01-16 06:19:38 -08:00
|
|
|
//! returns how much was written
|
|
|
|
virtual s32 write(const void* buffer, u32 sizeToWrite);
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
//! changes position in file, returns true if successful
|
2007-09-14 01:29:18 -07:00
|
|
|
virtual bool seek(long finalPos, bool relativeMovement = false);
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! returns size of file
|
2007-09-17 09:09:50 -07:00
|
|
|
virtual long getSize() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! returns where in the file we are.
|
2007-09-17 09:09:50 -07:00
|
|
|
virtual long getPos() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! returns name of file
|
2009-08-24 02:12:27 -07:00
|
|
|
virtual const io::path& getFileName() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void *Buffer;
|
2007-09-14 01:29:18 -07:00
|
|
|
long Len;
|
|
|
|
long Pos;
|
2009-08-24 02:12:27 -07:00
|
|
|
io::path Filename;
|
2007-05-20 11:03:49 -07:00
|
|
|
bool deleteMemoryWhenDropped;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace io
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|