49#if LASS_PLATFORM_TYPE == LASS_PLATFORM_TYPE_WIN32
50# pragma warning(disable: 4996)
92#if LASS_HAVE_WCHAR_SUPPORT
118#if LASS_HAVE_STD_FILESYSTEM
142void BinaryOFile::open(
const char* path)
144#if LASS_HAVE_WCHAR_SUPPORT && LASS_HAVE_WFOPEN
145 open(util::utf8ToWchar(path));
150 file_ = ::fopen(path,
"wb");
153 setstate(std::ios_base::failbit);
161void BinaryOFile::open(
const std::string& path)
168#if LASS_HAVE_WCHAR_SUPPORT
170void BinaryOFile::open(
const wchar_t* path)
176 file_ = ::_wfopen(path, L
"wb");
179 setstate(std::ios_base::failbit);
183 open(util::wcharToUtf8(path));
189void BinaryOFile::open(
const std::wstring& path)
198#if LASS_HAVE_STD_FILESYSTEM
200void BinaryOFile::open(
const std::filesystem::path& path)
206 file_ = ::_wfopen(path.c_str(), L
"wb");
208 file_ = ::fopen(path.c_str(),
"wb");
212 setstate(std::ios_base::failbit);
221void BinaryOFile::close()
225 const int result = ::fclose( file_ );
228 setstate(std::ios_base::failbit);
236bool BinaryOFile::is_open()
const
243BinaryOFile::pos_type BinaryOFile::doTellp()
const
245#if LASS_COMPILER_TYPE == LASS_COMPILER_TYPE_MSVC && LASS_ADDRESS_SIZE == 64
246 const off_type pos = ::_ftelli64(file_);
248 const off_type pos = ::ftell(file_);
250 return static_cast<pos_type
>(pos >= 0 ? pos : -1);
255void BinaryOFile::doSeekp(pos_type position)
257 if (position > num::NumTraits<off_type>::max)
259 setstate(std::ios_base::failbit);
262 doSeekp(
static_cast<off_type
>(position), std::ios_base::beg);
266void BinaryOFile::doSeekp(off_type offset, std::ios_base::seekdir direction)
268#if LASS_COMPILER_TYPE == LASS_COMPILER_TYPE_MSVC && LASS_ADDRESS_SIZE == 64
269 const int result = ::_fseeki64(file_, offset, impl::seekdir2stdio(direction));
271 const int result = ::fseek(file_, offset, impl::seekdir2stdio(direction));
275 setstate(std::ios_base::failbit);
281void BinaryOFile::doFlush()
285 setstate(std::ios_base::failbit);
292 const int result = ::fflush(file_);
295 setstate(std::ios_base::badbit);
305size_t BinaryOFile::doWrite(
const void* iBytes,
size_t iNumberOfBytes)
309 setstate(std::ios_base::failbit);
316 const size_t bytesWritten = ::fwrite( iBytes, 1, iNumberOfBytes, file_ );
317 if (bytesWritten != iNumberOfBytes)
319 setstate(std::ios_base::badbit);
~BinaryOFile()
Close stream on destruction.
BinaryOFile()
Construct an "empty" closed file.
base class of binary output streams.
streams, binary streams, vrmlstreams, ...
Library for Assembled Shared Sources.