Support fseek/ftell

This commit is contained in:
momo5502
2024-10-23 06:27:43 +02:00
parent a8df5f6fc8
commit 2938b1bf12
2 changed files with 118 additions and 7 deletions

View File

@@ -59,6 +59,27 @@ namespace utils
return this->file_;
}
[[nodiscard]] int64_t size() const
{
const auto current_position = this->tell();
this->seek_to(0, SEEK_END);
const auto size = this->tell();
this->seek_to(current_position);
return size;
}
bool seek_to(const int64_t position, const int origin = SEEK_SET) const
{
return _fseeki64(this->file_, position, origin) == 0;
}
[[nodiscard]] int64_t tell() const
{
return _ftelli64(this->file_);
}
private:
FILE* file_{};