Skip to content

Commit

Permalink
Maybe fix build when VS2013 is used
Browse files Browse the repository at this point in the history
  • Loading branch information
slime73 committed May 29, 2023
1 parent 63f0af8 commit 93c2709
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions src/modules/filesystem/physfs/PhysfsIo.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,31 @@ namespace physfs
{

template <typename Derived>
struct PhysfsIo : PHYSFS_Io {
struct PhysfsIo : PHYSFS_Io
{
protected:

PhysfsIo()
: PHYSFS_Io
{
/*.version =*/ Derived::version,
/*.opaque =*/ this,
/*.read =*/ staticRead, // may be NULL
/*.write =*/ staticWrite, // may be NULL
/*.seek =*/ staticSeek,
/*.tell =*/ staticTell,
/*.length =*/ staticLength,
/*.duplicate =*/ staticDuplicate,
/*.flush =*/ staticFlush, // may be NULL
/*.destroy =*/ staticDestroy,
}
: PHYSFS_Io()
{
// Direct initialization of PHYSFS_Io members in the initializer list
// doesn't work in VS2013.
this->version = Derived::version;
this->opaque = this;
this->read = staticRead; // May be null.
this->write = staticWrite; // May be null.
this->seek = staticSeek;
this->tell = staticTell;
this->length = staticLength;
this->duplicate = staticDuplicate;
this->flush = staticFlush; // May be null.
this->destroy = staticDestroy;
}

virtual ~PhysfsIo() {}

private:

// Returns: number of bytes read, 0 on EOF, -1 on failure
static PHYSFS_sint64 staticRead(struct PHYSFS_Io* io, void* buf, PHYSFS_uint64 len)
{
Expand Down Expand Up @@ -109,7 +114,8 @@ struct PhysfsIo : PHYSFS_Io {
}
};

struct StripSuffixIo : public PhysfsIo<StripSuffixIo> {
struct StripSuffixIo : public PhysfsIo<StripSuffixIo>
{
static const uint32_t version = 0;

std::string filename;
Expand All @@ -119,7 +125,7 @@ struct StripSuffixIo : public PhysfsIo<StripSuffixIo> {
// because Physfs will take ownership of this object and call destroy on it later.
static StripSuffixIo* create(std::string f) { return new StripSuffixIo(f); }

~StripSuffixIo()
virtual ~StripSuffixIo()
{
if (file)
{
Expand All @@ -142,6 +148,7 @@ struct StripSuffixIo : public PhysfsIo<StripSuffixIo> {
int64_t flush();

private:

StripSuffixIo(std::string f)
: filename(std::move(f))
, file(std::fopen(filename.c_str(), "rb"))
Expand Down

0 comments on commit 93c2709

Please sign in to comment.