diff --git a/source/libsmackerdec/include/FileStream.h b/source/libsmackerdec/include/FileStream.h index fb0d8c696..81983559f 100644 --- a/source/libsmackerdec/include/FileStream.h +++ b/source/libsmackerdec/include/FileStream.h @@ -50,11 +50,10 @@ class FileStream kSeekEnd = 2 }; - bool Seek(int32_t offset, SeekDirection = kSeekStart); - bool Skip(int32_t offset); + int32_t Seek(int32_t offset, SeekDirection = kSeekStart); + int32_t Skip(int32_t offset); int32_t GetPosition(); - bool Is_Eos(); private: FileReader file; diff --git a/source/libsmackerdec/src/FileStream.cpp b/source/libsmackerdec/src/FileStream.cpp index 5676e2bd3..772b8bcb2 100644 --- a/source/libsmackerdec/src/FileStream.cpp +++ b/source/libsmackerdec/src/FileStream.cpp @@ -85,7 +85,7 @@ uint8_t FileStream::ReadByte() return file.ReadInt8(); } -bool FileStream::Seek(int32_t offset, SeekDirection direction) +int32_t FileStream::Seek(int32_t offset, SeekDirection direction) { int32_t nStatus = -1; if (kSeekStart == direction) { @@ -94,28 +94,18 @@ bool FileStream::Seek(int32_t offset, SeekDirection direction) else if (kSeekCurrent == direction) { nStatus = file.Seek(offset, FileReader::SeekCur); } + else if (kSeekEnd == direction) { + nStatus = klseek(file, offset, SEEK_END); + } - // TODO - end seek - if (nStatus < 0) - { - // todo - return false; - } - - return true; + return nStatus; } -bool FileStream::Skip(int32_t offset) +int32_t FileStream::Skip(int32_t offset) { return Seek(offset, kSeekCurrent); } -bool FileStream::Is_Eos() -{ - // TODO: - return false; -} - int32_t FileStream::GetPosition() { return file.Tell(); diff --git a/source/rr/src/filestream.cpp b/source/rr/src/filestream.cpp index 3d72827cd..ded1dbaf5 100644 --- a/source/rr/src/filestream.cpp +++ b/source/rr/src/filestream.cpp @@ -104,38 +104,30 @@ uint8_t FileStream::ReadByte() return value; } -bool FileStream::Seek(int32_t offset, SeekDirection direction) +int32_t FileStream::Seek(int32_t offset, SeekDirection direction) { int32_t nStatus = -1; - - if (kSeekStart == direction) { + if (kSeekStart == direction) + { nStatus = klseek(file, offset, SEEK_SET); } - else if (kSeekCurrent == direction) { + else if (kSeekCurrent == direction) + { nStatus = klseek(file, offset, SEEK_CUR); } - - // TODO - end seek - if (nStatus < 0) + else if (kSeekEnd == direction) { - // todo - return false; + nStatus = klseek(file, offset, SEEK_END); } - return true; + return nStatus; } -bool FileStream::Skip(int32_t offset) +int32_t FileStream::Skip(int32_t offset) { return Seek(offset, kSeekCurrent); } -bool FileStream::Is_Eos() -{ - // TODO: - return false; -} - int32_t FileStream::GetPosition() { return ktell(file); diff --git a/source/rr/src/filestream.h b/source/rr/src/filestream.h index d7af3b5b4..190446988 100644 --- a/source/rr/src/filestream.h +++ b/source/rr/src/filestream.h @@ -51,11 +51,10 @@ class FileStream kSeekEnd = 2 }; - bool Seek(int32_t offset, SeekDirection = kSeekStart); - bool Skip(int32_t offset); + int32_t Seek(int32_t offset, SeekDirection = kSeekStart); + int32_t Skip(int32_t offset); int32_t GetPosition(); - bool Is_Eos(); private: buildvfs_kfd file;