diff --git a/source/games/duke/src/filestream.h b/source/games/duke/src/filestream.h deleted file mode 100644 index 190446988..000000000 --- a/source/games/duke/src/filestream.h +++ /dev/null @@ -1,65 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2010-2020 EDuke32 developers and contributors -Copyright (C) 2020 sirlemonhead -This file is part of Rednukem. -Rednukem is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- - -#ifndef _RedNukemFileStream_h_ -#define _RedNukemFileStream_h_ - -#include "vfs.h" -#include "compat.h" -#include - -namespace RedNukem { - -class FileStream -{ - public: - bool Open(const char *fileName); - bool Is_Open(); - void Close(); - - int32_t ReadBytes(uint8_t *data, uint32_t nBytes); - - uint64_t ReadUint64LE(); - uint64_t ReadUint64BE(); - - uint32_t ReadUint32LE(); - uint32_t ReadUint32BE(); - - uint16_t ReadUint16LE(); - uint16_t ReadUint16BE(); - - uint8_t ReadByte(); - - enum SeekDirection { - kSeekCurrent = 0, - kSeekStart = 1, - kSeekEnd = 2 - }; - - int32_t Seek(int32_t offset, SeekDirection = kSeekStart); - int32_t Skip(int32_t offset); - - int32_t GetPosition(); - - private: - buildvfs_kfd file; -}; - -} // close namespace RedNukem - -#endif diff --git a/source/libsmackerdec/include/FileStream.h b/source/libsmackerdec/include/FileStream.h index 35e1481a1..e344ee332 100644 --- a/source/libsmackerdec/include/FileStream.h +++ b/source/libsmackerdec/include/FileStream.h @@ -30,29 +30,29 @@ class FileStream public: bool Open(const char *fileName); - bool Is_Open(); - void Close(); + bool Is_Open() { return file.isOpen(); } + void Close() { file.Close(); } - int32_t ReadBytes(uint8_t *data, uint32_t nBytes); + int32_t ReadBytes(uint8_t *data, uint32_t nBytes) + { + return (uint32_t)file.Read(data, static_cast(nBytes)); + } - uint32_t ReadUint32LE(); - uint32_t ReadUint32BE(); + uint64_t ReadUint64LE() { return file.ReadUInt64(); } + uint32_t ReadUint32LE() { return file.ReadUInt32(); } + uint16_t ReadUint16LE() { return file.ReadUInt16(); } + uint8_t ReadByte() { return file.ReadInt8(); } - uint16_t ReadUint16LE(); - uint16_t ReadUint16BE(); - - uint8_t ReadByte(); enum SeekDirection{ - kSeekCurrent = 0, - kSeekStart = 1, - kSeekEnd = 2 + kSeekCurrent = SEEK_CUR, + kSeekStart = SEEK_SET, + kSeekEnd = SEEK_END }; - int32_t Seek(int32_t offset, SeekDirection = kSeekStart); - int32_t Skip(int32_t offset); - - int32_t GetPosition(); + int32_t Seek(int32_t offset, SeekDirection dir = kSeekStart) { return file.Seek(offset, (FileReader::ESeek) dir); } + int32_t Skip(int32_t offset) { return Seek(offset, kSeekCurrent); } + int32_t GetPosition() { return file.Tell(); } private: FileReader file;