mirror of https://github.com/libAthena/athena.git
42 lines
900 B
C++
42 lines
900 B
C++
#ifndef FILEWRITER_HPP
|
|
#define FILEWRITER_HPP
|
|
|
|
#include "Athena/IStreamWriter.hpp"
|
|
#include <stdio.h>
|
|
|
|
namespace Athena
|
|
{
|
|
namespace io
|
|
{
|
|
class FileWriter : public IStreamWriter
|
|
{
|
|
public:
|
|
FileWriter(const std::string& filename, bool overwrite = true);
|
|
virtual ~FileWriter();
|
|
|
|
void open(bool overwrite = true);
|
|
void close();
|
|
inline bool isOpen() const
|
|
{return m_fileHandle != NULL;}
|
|
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current);
|
|
atUint64 position() const;
|
|
atUint64 length() const;
|
|
void writeUBytes(const atUint8* data, atUint64 len);
|
|
|
|
private:
|
|
std::string m_filename;
|
|
FILE* m_fileHandle;
|
|
atUint8 m_currentByte;
|
|
atUint64 m_bytePosition;
|
|
};
|
|
}
|
|
} // Athena
|
|
|
|
#ifndef FILEWRITER_BASE
|
|
#define FILEWRITER_BASE() \
|
|
private: \
|
|
typedef Athena::io::FileWriter base;
|
|
|
|
#endif // FILEWRITER_BASE
|
|
#endif // FILEWRITER_HPP
|