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"
|
2015-05-21 04:57:27 +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 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);
|
2015-07-22 18:59:40 +00:00
|
|
|
#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;}
|
2014-06-18 04:51:18 +00:00
|
|
|
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);
|
2015-07-08 02:53:39 +00:00
|
|
|
|
2014-04-20 09:14:15 +00:00
|
|
|
private:
|
|
|
|
std::string m_filename;
|
2015-07-22 18:59:40 +00:00
|
|
|
#if _WIN32
|
|
|
|
std::wstring m_wfilename;
|
|
|
|
#endif
|
2014-04-20 09:14:15 +00:00
|
|
|
FILE* m_fileHandle;
|
2014-12-29 04:46:43 +00:00
|
|
|
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
|