athena/include/Athena/FileWriter.hpp

49 lines
1.1 KiB
C++
Raw Normal View History

2014-04-20 09:14:15 +00:00
#ifndef FILEWRITER_HPP
#define FILEWRITER_HPP
2015-03-01 20:42:39 +00:00
#include "Athena/IStreamWriter.hpp"
#include <stdio.h>
2014-04-20 09:14:15 +00:00
namespace Athena
{
namespace io
{
2015-03-01 20:42:39 +00:00
class FileWriter : public IStreamWriter
2014-04-20 09:14:15 +00:00
{
public:
2015-05-18 21:03:13 +00:00
FileWriter(const std::string& filename, bool overwrite = true);
#if _WIN32
FileWriter(const std::wstring& filename, bool overwrite = true);
#endif
2015-01-29 06:31:14 +00:00
virtual ~FileWriter();
2014-04-20 09:14:15 +00:00
2015-05-18 21:03:13 +00:00
void open(bool overwrite = true);
2014-04-20 09:14:15 +00:00
void close();
2015-07-01 09:28:40 +00:00
inline bool isOpen() const
{return m_fileHandle != NULL;}
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current);
atUint64 position() const;
atUint64 length() const;
2015-07-01 03:01:04 +00:00
void writeUBytes(const atUint8* data, atUint64 len);
FILE* _fileHandle() {return m_fileHandle;}
2014-04-20 09:14:15 +00:00
private:
std::string m_filename;
#if _WIN32
std::wstring m_wfilename;
#endif
2014-04-20 09:14:15 +00:00
FILE* m_fileHandle;
atUint8 m_currentByte;
atUint64 m_bytePosition;
2014-04-20 09:14:15 +00:00
};
}
} // Athena
2014-04-25 02:01:24 +00:00
#ifndef FILEWRITER_BASE
2015-03-01 20:42:39 +00:00
#define FILEWRITER_BASE() \
2014-04-25 02:01:24 +00:00
private: \
typedef Athena::io::FileWriter base;
#endif // FILEWRITER_BASE
2014-04-20 09:14:15 +00:00
#endif // FILEWRITER_HPP