49 lines
910 B
C
49 lines
910 B
C
|
#ifndef IOUTILITIES_NATIVE_FILE_STREAM
|
||
|
#define IOUTILITIES_NATIVE_FILE_STREAM
|
||
|
|
||
|
#include "../global.h"
|
||
|
|
||
|
#ifndef PLATFORM_MINGW
|
||
|
# include <fstream>
|
||
|
#else
|
||
|
# include "../misc/memory.h"
|
||
|
# include <string>
|
||
|
# include <iostream>
|
||
|
# include <ext/stdio_filebuf.h>
|
||
|
#endif
|
||
|
|
||
|
namespace IoUtilities {
|
||
|
|
||
|
#if !defined(PLATFORM_MINGW) || !defined(CPP_UTILITIES_USE_NATIVE_FILE_BUFFER)
|
||
|
|
||
|
typedef std::fstream NativeFileStream;
|
||
|
|
||
|
#else
|
||
|
|
||
|
class CPP_UTILITIES_EXPORT NativeFileStream : public std::iostream
|
||
|
{
|
||
|
public:
|
||
|
NativeFileStream();
|
||
|
~NativeFileStream();
|
||
|
|
||
|
bool is_open() const;
|
||
|
void open(const std::string &path, std::ios_base::openmode flags);
|
||
|
void close();
|
||
|
|
||
|
private:
|
||
|
std::unique_ptr<__gnu_cxx::stdio_filebuf<char> > m_filebuf;
|
||
|
std::__c_file m_cfile;
|
||
|
};
|
||
|
|
||
|
inline bool NativeFileStream::is_open() const
|
||
|
{
|
||
|
return m_filebuf && m_filebuf->is_open();
|
||
|
}
|
||
|
|
||
|
#endif
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif // IOUTILITIES_NATIVE_FILE_STREAM
|
||
|
|