From e4a45f3ce6c519ae981091a7c38a403f7f533376 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 2 Dec 2019 16:05:57 +0100 Subject: [PATCH] Delegate seekpos to seekoff Calling fsetpos requires correct argument of type off_t which is not available. For simplicity assume fseek acts the same. --- include/boost/nowide/filebuf.hpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/include/boost/nowide/filebuf.hpp b/include/boost/nowide/filebuf.hpp index 953e761..236b1a6 100644 --- a/include/boost/nowide/filebuf.hpp +++ b/include/boost/nowide/filebuf.hpp @@ -288,18 +288,10 @@ namespace nowide { return EOF; return std::ftell(file_); } - virtual std::streampos seekpos(std::streampos pos, std::ios_base::openmode = std::ios_base::in | std::ios_base::out) + virtual std::streampos seekpos(std::streampos pos, std::ios_base::openmode m = std::ios_base::in | std::ios_base::out) { - if(!file_) - return EOF; - // On some implementations a seek also flushes, so do a full sync - if(sync() != 0) - return EOF; - std::streamoff off = static_cast(pos); - if(std::fsetpos(file_, &off) != 0) - return EOF; - assert(std::ftell(file_) == off); - return pos; + // Standard mandates "as-if fsetpos", but assume the effect is the same as fseek + return seekoff(pos, std::ios_base::beg, m); } virtual void imbue(const std::locale &loc) {