summaryrefslogtreecommitdiff
path: root/src/utils/virtfsrwops.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-02-11 17:13:02 +0300
committerAndrei Karas <akaras@inbox.ru>2017-02-11 17:44:15 +0300
commitf978c1bed85961e102951340669ca873328bcef3 (patch)
treee7f67d2806f72cccc028be95f3c3e00679368d20 /src/utils/virtfsrwops.cpp
parent083160ca5bdc366e4849c1f73e718531250a9e7c (diff)
downloadManaVerse-f978c1bed85961e102951340669ca873328bcef3.tar.gz
ManaVerse-f978c1bed85961e102951340669ca873328bcef3.tar.bz2
ManaVerse-f978c1bed85961e102951340669ca873328bcef3.tar.xz
ManaVerse-f978c1bed85961e102951340669ca873328bcef3.zip
Add VirtFile struct and replace all Phyfs_file usage to this struct.
Diffstat (limited to 'src/utils/virtfsrwops.cpp')
-rw-r--r--src/utils/virtfsrwops.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/utils/virtfsrwops.cpp b/src/utils/virtfsrwops.cpp
index 731eb12a8..ce4f0cec9 100644
--- a/src/utils/virtfsrwops.cpp
+++ b/src/utils/virtfsrwops.cpp
@@ -53,6 +53,9 @@
#endif // DEBUG_VIRTFS
#include "utils/fuzzer.h"
+#include "utils/virtfile.h"
+#include "utils/virtfileprivate.h"
+#include "utils/virtfs.h"
#include "debug.h"
@@ -138,7 +141,7 @@ static RWOPSINT virtfsrwops_seek(SDL_RWops *const rw,
{
if (!rw)
return -1;
- PHYSFS_file *const handle = static_cast<PHYSFS_file *const>(
+ VirtFile *const handle = static_cast<VirtFile *const>(
rw->hidden.unknown.data1);
RWOPSINT pos = 0;
@@ -220,7 +223,7 @@ static RWOPSSIZE virtfsrwops_read(SDL_RWops *const rw,
{
if (!rw)
return 0;
- PHYSFS_file *const handle = static_cast<PHYSFS_file *const>(
+ VirtFile *const handle = static_cast<VirtFile *const>(
rw->hidden.unknown.data1);
const int64_t rc = VirtFs::read(handle, ptr,
CAST_U32(size),
@@ -244,7 +247,7 @@ static RWOPSSIZE virtfsrwops_write(SDL_RWops *const rw,
{
if (!rw)
return 0;
- PHYSFS_file *const handle = static_cast<PHYSFS_file *const>(
+ VirtFile *const handle = static_cast<VirtFile *const>(
rw->hidden.unknown.data1);
const int64_t rc = VirtFs::write(handle, ptr,
CAST_U32(size),
@@ -262,7 +265,7 @@ static int virtfsrwops_close(SDL_RWops *const rw)
{
if (!rw)
return 0;
- PHYSFS_file *const handle = static_cast<PHYSFS_file*>(
+ VirtFile *const handle = static_cast<VirtFile*>(
rw->hidden.unknown.data1);
if (!VirtFs::close(handle))
{
@@ -287,17 +290,17 @@ static int virtfsrwops_close(SDL_RWops *const rw)
#ifdef USE_SDL2
static RWOPSINT virtfsrwops_size(SDL_RWops *const rw)
{
- PHYSFS_file *const handle = static_cast<PHYSFS_file*>(
+ VirtFile *const handle = static_cast<VirtFile *const>(
rw->hidden.unknown.data1);
return VirtFs::fileLength(handle);
} /* virtfsrwops_size */
#endif // USE_SDL2
-static SDL_RWops *create_rwops(PHYSFS_file *const handle)
+static SDL_RWops *create_rwops(VirtFile *const file)
{
SDL_RWops *retval = nullptr;
- if (!handle)
+ if (!file)
{
logger->assertLog("virtfsrwops_seek: create rwops error: %s",
VirtFs::getLastError());
@@ -315,7 +318,7 @@ static SDL_RWops *create_rwops(PHYSFS_file *const handle)
retval->read = &virtfsrwops_read;
retval->write = &virtfsrwops_write;
retval->close = &virtfsrwops_close;
- retval->hidden.unknown.data1 = handle;
+ retval->hidden.unknown.data1 = file;
} /* if */
#ifdef DUMP_LEAKED_RESOURCES
openedRWops ++;
@@ -325,7 +328,7 @@ static SDL_RWops *create_rwops(PHYSFS_file *const handle)
return retval;
} /* create_rwops */
-SDL_RWops *VirtFs::MakeRWops(PHYSFS_file *const handle)
+SDL_RWops *VirtFs::MakeRWops(VirtFile *const handle)
{
SDL_RWops *retval = nullptr;
if (!handle)