- fixed some remaining issues:

* initial positioning in a subsection of a file failed. This mainly affected music playback.
* made the FileRdr constructor which takes a FileReaderInterface private so that everything that needs it must be explicitly declared as friend.
* removed a few redundant construction initializers for FileRdrs.
* loading compressed nodes needs to check the validity of its reader.
* use GetLength to detemine the size of a Zip file instead of doing another seek to the end.
* removed duplicate Length variables.
This commit is contained in:
Christoph Oelckers 2018-03-11 13:26:30 +01:00
commit 8bbfd39f42
7 changed files with 42 additions and 39 deletions

View file

@ -51,7 +51,6 @@
class StdFileReader : public FileReaderInterface
{
FILE *File = nullptr;
long Length = 0;
long StartPos = 0;
long FilePos = 0;
@ -76,7 +75,7 @@ public:
StartPos = startpos;
Length = CalcFileLen();
if (len >= 0 && len < Length) Length = len;
if (startpos > 0) Seek(startpos, SEEK_SET);
if (startpos > 0) Seek(0, SEEK_SET);
return true;
}
@ -99,7 +98,7 @@ public:
{
offset += StartPos + Length;
}
if (offset < StartPos || offset >= StartPos + Length) return -1; // out of scope
if (offset < StartPos || offset > StartPos + Length) return -1; // out of scope
if (0 == fseek(File, offset, SEEK_SET))
{
@ -161,7 +160,6 @@ private:
class FileReaderRedirect : public FileReaderInterface
{
FileRdr *mReader = nullptr;
long Length = 0;
long StartPos = 0;
long FilePos = 0;
@ -196,7 +194,7 @@ public:
offset += (long)mReader->Tell();
break;
}
if (offset < StartPos || offset >= StartPos + Length) return -1; // out of scope
if (offset < StartPos || offset > StartPos + Length) return -1; // out of scope
if (mReader->Seek(offset, FileRdr::SeekSet) == 0)
{
FilePos = offset;