2009-01-14 04:37:51 -08:00
|
|
|
// Copyright (C) 2002-2009 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_LIMIT_READ_FILE_H_INCLUDED__
|
|
|
|
#define __C_LIMIT_READ_FILE_H_INCLUDED__
|
|
|
|
|
|
|
|
#include "IReadFile.h"
|
|
|
|
#include "irrString.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
class CUnicodeConverter;
|
|
|
|
|
|
|
|
namespace io
|
|
|
|
{
|
|
|
|
|
|
|
|
/*! this is a read file, which is limited to some boundaries,
|
|
|
|
so that it may only start from a certain file position
|
|
|
|
and may only read until a certain file position.
|
|
|
|
This can be useful, for example for reading uncompressed files
|
|
|
|
in an archive (zip).
|
|
|
|
!*/
|
|
|
|
class CLimitReadFile : public IReadFile
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2007-09-14 01:29:18 -07:00
|
|
|
CLimitReadFile(IReadFile* alreadyOpenedFile, long areaSize, const c8* name);
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
virtual ~CLimitReadFile();
|
|
|
|
|
|
|
|
//! returns how much was read
|
|
|
|
virtual s32 read(void* buffer, u32 sizeToRead);
|
|
|
|
|
|
|
|
//! changes position in file, returns true if successful
|
|
|
|
//! if relativeMovement==true, the pos is changed relative to current pos,
|
|
|
|
//! otherwise from begin of file
|
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
|
2007-09-14 01:29:18 -07:00
|
|
|
virtual const c8* getFileName() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void init();
|
|
|
|
|
|
|
|
core::stringc Filename;
|
2007-09-14 01:29:18 -07:00
|
|
|
long AreaSize;
|
|
|
|
long AreaStart;
|
|
|
|
long AreaEnd;
|
2007-05-20 11:03:49 -07:00
|
|
|
IReadFile* File;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace io
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|