mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 20:20:40 +00:00
Clean up the FileStream code: Remove non-working Is_Eos() and make Seek() and Skip() return int.
This commit is contained in:
parent
6f64967d00
commit
17be2617cf
4 changed files with 19 additions and 39 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue