1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-04 05:13:19 +00:00

ttvfs related cleanups

This commit is contained in:
fgenesis 2014-04-15 19:48:06 +02:00
commit f69d88b656
7 changed files with 69 additions and 56 deletions

View file

@ -44,6 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <assert.h>
#ifdef BBGE_BUILD_VFS
#include "ttvfs.h"
ttvfs::Root vfs; // extern
#endif

View file

@ -295,6 +295,7 @@ void triggerBreakpoint();
bool createDir(const std::string& d);
#ifdef BBGE_BUILD_VFS
namespace ttvfs { class Root; }
extern ttvfs::Root vfs; // in Base.cpp
#endif

View file

@ -57,6 +57,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Vector unchange;
#endif
#ifdef BBGE_BUILD_VFS
#include "ttvfs.h"
#endif
Core *core = 0;
#ifdef BBGE_BUILD_WINDOWS

View file

@ -134,73 +134,68 @@ using namespace SoundCore;
FMOD_RESULT F_CALLBACK myopen(const char *name, int unicode, unsigned int *filesize, void **handle, void **userdata)
{
if (name)
{
VFILE *fp;
if (name)
{
VFILE *fp = vfopen(name, "rb");
if (!fp)
return FMOD_ERR_FILE_NOTFOUND;
size_t sz = 0;
if(vfsize(fp, &sz) < 0)
{
vfclose(fp);
return FMOD_ERR_FILE_NOTFOUND;
}
fp = vfopen(name, "rb");
if (!fp)
{
return FMOD_ERR_FILE_NOTFOUND;
}
*filesize = (unsigned int)sz;
*userdata = (void *)0x12345678;
*handle = fp;
}
#ifdef BBGE_BUILD_VFS
*filesize = fp->size();
#else
vfseek(fp, 0, SEEK_END);
*filesize = ftell(fp);
vfseek(fp, 0, SEEK_SET);
#endif
*userdata = (void *)0x12345678;
*handle = fp;
}
return FMOD_OK;
return FMOD_OK;
}
FMOD_RESULT F_CALLBACK myclose(void *handle, void *userdata)
{
if (!handle)
{
return FMOD_ERR_INVALID_PARAM;
}
if (!handle)
{
return FMOD_ERR_INVALID_PARAM;
}
vfclose((VFILE *)handle);
vfclose((VFILE *)handle);
return FMOD_OK;
return FMOD_OK;
}
FMOD_RESULT F_CALLBACK myread(void *handle, void *buffer, unsigned int sizebytes, unsigned int *bytesread, void *userdata)
{
if (!handle)
{
return FMOD_ERR_INVALID_PARAM;
}
if (!handle)
{
return FMOD_ERR_INVALID_PARAM;
}
if (bytesread)
{
*bytesread = (int)vfread(buffer, 1, sizebytes, (VFILE *)handle);
if (*bytesread < sizebytes)
{
return FMOD_ERR_FILE_EOF;
}
}
if (bytesread)
{
*bytesread = (int)vfread(buffer, 1, sizebytes, (VFILE *)handle);
return FMOD_OK;
if (*bytesread < sizebytes)
{
return FMOD_ERR_FILE_EOF;
}
}
return FMOD_OK;
}
FMOD_RESULT F_CALLBACK myseek(void *handle, unsigned int pos, void *userdata)
{
if (!handle)
{
return FMOD_ERR_INVALID_PARAM;
}
if (!handle)
{
return FMOD_ERR_INVALID_PARAM;
}
vfseek((VFILE *)handle, pos, SEEK_SET);
vfseek((VFILE *)handle, pos, SEEK_SET);
return FMOD_OK;
return FMOD_OK;
}