2
0
mirror of https://github.com/boostorg/nowide.git synced 2026-02-26 16:52:30 +00:00

Delegate seekpos to seekoff

Calling fsetpos requires correct argument of type off_t which is not
available. For simplicity assume fseek acts the same.
This commit is contained in:
Alexander Grund
2019-12-02 16:05:57 +01:00
parent 97dba5bc1e
commit e4a45f3ce6

View File

@@ -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<std::streamoff>(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)
{