2014-04-20 09:14:15 +00:00
|
|
|
#ifndef FILESTREAM_HPP
|
|
|
|
#define FILESTREAM_HPP
|
|
|
|
|
2015-03-01 20:42:39 +00:00
|
|
|
#include "Athena/IStreamReader.hpp"
|
2014-04-20 09:14:15 +00:00
|
|
|
#include <string>
|
2015-05-18 21:03:13 +00:00
|
|
|
#include <stdio.h>
|
2014-04-20 09:14:15 +00:00
|
|
|
|
|
|
|
namespace Athena
|
|
|
|
{
|
|
|
|
namespace io
|
|
|
|
{
|
2015-03-01 20:42:39 +00:00
|
|
|
class FileReader : public IStreamReader
|
2014-04-20 09:14:15 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
FileReader(const std::string& filename);
|
2015-01-29 06:31:14 +00:00
|
|
|
virtual ~FileReader();
|
2015-07-01 09:28:40 +00:00
|
|
|
inline const std::string& filename() const
|
|
|
|
{return m_filename;}
|
|
|
|
|
2014-04-20 09:14:15 +00:00
|
|
|
void open();
|
|
|
|
void close();
|
2015-07-01 09:28:40 +00:00
|
|
|
inline bool isOpen() const
|
|
|
|
{return m_fileHandle != NULL;}
|
2014-04-20 09:14:15 +00:00
|
|
|
bool save();
|
2014-06-18 04:51:18 +00:00
|
|
|
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current);
|
|
|
|
atUint64 position() const;
|
|
|
|
atUint64 length() const;
|
2015-04-11 00:04:13 +00:00
|
|
|
atUint64 readUBytesToBuf(void* buf, atUint64 len);
|
2015-07-08 02:53:39 +00:00
|
|
|
|
2015-01-29 06:20:57 +00:00
|
|
|
protected:
|
2014-04-20 09:14:15 +00:00
|
|
|
std::string m_filename;
|
|
|
|
FILE* m_fileHandle;
|
2015-07-08 02:53:39 +00:00
|
|
|
atUint8 m_currentByte;
|
2014-04-20 09:14:15 +00:00
|
|
|
};
|
|
|
|
} // io
|
|
|
|
} // Athena
|
|
|
|
|
2014-04-25 02:01:24 +00:00
|
|
|
#ifndef FILEREADER_BASE
|
2015-01-29 06:20:57 +00:00
|
|
|
#define FILEREADER_BASE() \
|
2014-04-25 02:01:24 +00:00
|
|
|
private: \
|
2015-01-29 06:20:57 +00:00
|
|
|
typedef Athena::io::FileReader base
|
2014-04-25 02:01:24 +00:00
|
|
|
|
|
|
|
#endif // FILEREADER_BASE
|
|
|
|
|
2014-04-20 09:14:15 +00:00
|
|
|
#endif // FILESTREAM_HPP
|