1#ifndef IOUTILITIES_NATIVE_FILE_STREAM
2#define IOUTILITIES_NATIVE_FILE_STREAM
6#ifdef CPP_UTILITIES_USE_NATIVE_FILE_BUFFER
17#ifdef CPP_UTILITIES_USE_NATIVE_FILE_BUFFER
21#ifdef PLATFORM_WINDOWS
22 using Handle =
void *;
25 FileBuffer(std::basic_streambuf<char> *buffer);
26 FileBuffer(
const char *path, ios_base::openmode openMode);
27 FileBuffer(
const std::string &path, ios_base::openmode openMode);
28 FileBuffer(
int fileDescriptor, ios_base::openmode openMode);
30 std::unique_ptr<std::basic_streambuf<char>> buffer;
31#ifdef PLATFORM_WINDOWS
32 Handle handle =
nullptr;
42 ~NativeFileStream()
override;
46 void open(
const char *path, std::ios_base::openmode openMode);
47 void open(
const std::string &path, std::ios_base::openmode openMode);
48 void open(
int fileDescriptor, std::ios_base::openmode openMode);
51#ifdef PLATFORM_WINDOWS
53 static std::unique_ptr<wchar_t[]> makeWidePath(std::string_view path);
54 static std::unique_ptr<wchar_t[]> makeWidePath(
const char *path);
55 static std::unique_ptr<wchar_t[]> makeWidePath(
const std::string &path);
59 void setData(FileBuffer data, std::ios_base::openmode openMode);
62 std::ios_base::openmode m_openMode;
68inline NativeFileStream::NativeFileStream(
const char *path, ios_base::openmode openMode)
77inline NativeFileStream::NativeFileStream(
const std::string &path, ios_base::openmode openMode)
85inline NativeFileStream::NativeFileStream(
int fileDescriptor, ios_base::openmode openMode)
88 open(fileDescriptor, openMode);
95inline int NativeFileStream::fileDescriptor()
97 return m_data.descriptor;
100#ifdef PLATFORM_WINDOWS
105inline NativeFileStream::Handle NativeFileStream::fileHandle()
107 return m_data.handle;
114inline std::unique_ptr<wchar_t[]> NativeFileStream::makeWidePath(
const char *path)
116 return makeWidePath(std::string_view(path));
124inline bool NativeFileStream::is_open()
const
#define CPP_UTILITIES_EXPORT
Marks the symbol to be exported by the c++utilities library.
Contains all utilities provides by the c++utilities library.
std::fstream NativeFileStream