48#if LASS_PLATFORM_TYPE == LASS_PLATFORM_TYPE_WIN32
49# pragma warning(disable: 4996)
90#if LASS_HAVE_WCHAR_SUPPORT
116#if LASS_HAVE_STD_FILESYSTEM
140void BinaryIFile::open(
const char* path)
142#if LASS_HAVE_WCHAR_SUPPORT && LASS_HAVE_WFOPEN
143 open(util::utf8ToWchar(path));
146 file_ = ::fopen(path,
"rb");
149 setstate(std::ios_base::failbit);
156void BinaryIFile::open(
const std::string& path)
163#if LASS_HAVE_WCHAR_SUPPORT
165void BinaryIFile::open(
const wchar_t* path)
169 file_ = ::_wfopen(path, L
"rb");
172 setstate(std::ios_base::failbit);
175 open(util::wcharToUtf8(path));
181void BinaryIFile::open(
const std::wstring& path)
190#if LASS_HAVE_STD_FILESYSTEM
192void BinaryIFile::open(
const std::filesystem::path& path)
198 file_ = ::_wfopen(path.c_str(), L
"rb");
200 file_ = ::fopen(path.c_str(),
"rb");
204 setstate(std::ios_base::failbit);
213void BinaryIFile::close()
217 const int result = ::fclose( file_ );
220 setstate(std::ios_base::failbit);
226bool BinaryIFile::is_open()
const
235BinaryIFile::pos_type BinaryIFile::doTellg()
const
237#if LASS_COMPILER_TYPE == LASS_COMPILER_TYPE_MSVC && LASS_ADDRESS_SIZE == 64
238 const off_type pos = ::_ftelli64(file_);
240 const off_type pos = ::ftell(file_);
242 return static_cast<pos_type
>(pos >= 0 ? pos : -1);
247void BinaryIFile::doSeekg(pos_type position)
249 if (position > num::NumTraits<off_type>::max)
251 setstate(std::ios_base::failbit);
254 doSeekg(
static_cast<off_type
>(position), std::ios_base::beg);
259void BinaryIFile::doSeekg(off_type offset, std::ios_base::seekdir direction)
261#if LASS_COMPILER_TYPE == LASS_COMPILER_TYPE_MSVC && LASS_ADDRESS_SIZE == 64
262 const int result = ::_fseeki64(file_, offset, impl::seekdir2stdio(direction));
264 const int result = ::fseek(file_, offset, impl::seekdir2stdio(direction));
268 setstate(std::ios_base::failbit);
274size_t BinaryIFile::doRead(
void* output,
size_t numberOfBytes)
278 setstate(std::ios_base::failbit);
285 const size_t bytesRead = ::fread(output, 1, numberOfBytes, file_);
286 if (bytesRead != numberOfBytes)
288 setstate(std::ios_base::eofbit);
BinaryIFile()
Construct an "empty" closed stream.
~BinaryIFile()
Close stream on destruction.
base class of binary input streams.
streams, binary streams, vrmlstreams, ...
Library for Assembled Shared Sources.