Merge pull request #100 from mihaip/upstream-uint64_t

Switch ImgFile to using uint64_t explicitly
This commit is contained in:
dingusdev 2024-07-22 22:12:09 -07:00 committed by GitHub
commit ebc618adea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -37,10 +37,10 @@ public:
bool open(const std::string& img_path);
void close();
size_t size() const;
uint64_t size() const;
size_t read(void* buf, off_t offset, size_t length) const;
size_t write(const void* buf, off_t offset, size_t length);
uint64_t read(void* buf, uint64_t offset, uint64_t length) const;
uint64_t write(const void* buf, uint64_t offset, uint64_t length);
private:
class Impl; // Holds private fields
std::unique_ptr<Impl> impl;

View File

@ -46,20 +46,20 @@ void ImgFile::close()
impl->stream.close();
}
size_t ImgFile::size() const
uint64_t ImgFile::size() const
{
impl->stream.seekg(0, impl->stream.end);
return impl->stream.tellg();
}
size_t ImgFile::read(void* buf, off_t offset, size_t length) const
uint64_t ImgFile::read(void* buf, uint64_t offset, uint64_t length) const
{
impl->stream.seekg(offset, std::ios::beg);
impl->stream.read((char *)buf, length);
return impl->stream.gcount();
}
size_t ImgFile::write(const void* buf, off_t offset, size_t length)
uint64_t ImgFile::write(const void* buf, uint64_t offset, uint64_t length)
{
impl->stream.seekg(offset, std::ios::beg);
impl->stream.write((const char *)buf, length);