mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-03-10 02:21:41 +00:00
- FileStream cleanup
This commit is contained in:
parent
2ddec37098
commit
7b7c64fc17
2 changed files with 16 additions and 81 deletions
|
@ -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 <stdint.h>
|
|
||||||
|
|
||||||
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
|
|
|
@ -30,29 +30,29 @@ class FileStream
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool Open(const char *fileName);
|
bool Open(const char *fileName);
|
||||||
bool Is_Open();
|
bool Is_Open() { return file.isOpen(); }
|
||||||
void Close();
|
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<int32_t>(nBytes));
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t ReadUint32LE();
|
uint64_t ReadUint64LE() { return file.ReadUInt64(); }
|
||||||
uint32_t ReadUint32BE();
|
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{
|
enum SeekDirection{
|
||||||
kSeekCurrent = 0,
|
kSeekCurrent = SEEK_CUR,
|
||||||
kSeekStart = 1,
|
kSeekStart = SEEK_SET,
|
||||||
kSeekEnd = 2
|
kSeekEnd = SEEK_END
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t Seek(int32_t offset, SeekDirection = kSeekStart);
|
int32_t Seek(int32_t offset, SeekDirection dir = kSeekStart) { return file.Seek(offset, (FileReader::ESeek) dir); }
|
||||||
int32_t Skip(int32_t offset);
|
int32_t Skip(int32_t offset) { return Seek(offset, kSeekCurrent); }
|
||||||
|
int32_t GetPosition() { return file.Tell(); }
|
||||||
int32_t GetPosition();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FileReader file;
|
FileReader file;
|
||||||
|
|
Loading…
Reference in a new issue