From c9b44d08018342ddc150b9069ada2507664bedb8 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Wed, 11 Mar 2015 01:05:37 +0100 Subject: [PATCH] Fix file reading --- CryOpenFile.cpp | 6 ++---- CryOpenFile.h | 2 +- impl/FileBlob.cpp | 4 ++-- impl/FileBlob.h | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CryOpenFile.cpp b/CryOpenFile.cpp index 34224ea9..150d339b 100644 --- a/CryOpenFile.cpp +++ b/CryOpenFile.cpp @@ -40,10 +40,8 @@ void CryOpenFile::truncate(off_t size) const { _fileBlob->resize(size); } -int CryOpenFile::read(void *buf, size_t count, off_t offset) { - //TODO Return number of read bytes - _fileBlob->read(buf, offset, count); - return count; +ssize_t CryOpenFile::read(void *buf, size_t count, off_t offset) { + return _fileBlob->read(buf, offset, count); } void CryOpenFile::write(const void *buf, size_t count, off_t offset) { diff --git a/CryOpenFile.h b/CryOpenFile.h index aadc0752..496f7672 100644 --- a/CryOpenFile.h +++ b/CryOpenFile.h @@ -16,7 +16,7 @@ public: void stat(struct ::stat *result) const override; void truncate(off_t size) const override; - int read(void *buf, size_t count, off_t offset) override; + ssize_t read(void *buf, size_t count, off_t offset) override; void write(const void *buf, size_t count, off_t offset) override; void flush() override; void fsync() override; diff --git a/impl/FileBlob.cpp b/impl/FileBlob.cpp index 2e55a00c..aaa20e36 100644 --- a/impl/FileBlob.cpp +++ b/impl/FileBlob.cpp @@ -29,8 +29,8 @@ unsigned char FileBlob::magicNumber() const { return value; } -void FileBlob::read(void *target, uint64_t offset, uint64_t count) const { - _blob->read(target, offset + 1, count); +ssize_t FileBlob::read(void *target, uint64_t offset, uint64_t count) const { + return _blob->tryRead(target, offset + 1, count); } void FileBlob::write(const void *source, uint64_t offset, uint64_t count) { diff --git a/impl/FileBlob.h b/impl/FileBlob.h index dc055804..dae6ad64 100644 --- a/impl/FileBlob.h +++ b/impl/FileBlob.h @@ -14,7 +14,7 @@ public: FileBlob(std::unique_ptr blob); virtual ~FileBlob(); - void read(void *target, uint64_t offset, uint64_t count) const; + ssize_t read(void *target, uint64_t offset, uint64_t count) const; void write(const void *source, uint64_t offset, uint64_t count); void resize(off_t size);