1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2025-01-25 18:24:59 +01:00

Abstract zip loading to FileSystemUtils

editor.cpp no longer calls PhysFS functions directly; its physfs.h
include can now be dropped.
This commit is contained in:
Misa 2021-03-04 16:05:06 -08:00 committed by Ethan Lee
parent 7316833f95
commit d938a18504
3 changed files with 16 additions and 11 deletions

View file

@ -198,6 +198,20 @@ void FILESYSTEM_mount(const char *fname)
} }
} }
void FILESYSTEM_loadZip(const char* filename)
{
PHYSFS_File* zip = PHYSFS_openRead(filename);
if (!PHYSFS_mountHandle(zip, filename, "levels", 1))
{
printf(
"Could not mount %s: %s\n",
filename,
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
);
}
}
bool FILESYSTEM_assetsmounted = false; bool FILESYSTEM_assetsmounted = false;
void FILESYSTEM_mountassets(const char* path) void FILESYSTEM_mountassets(const char* path)

View file

@ -13,6 +13,7 @@ char *FILESYSTEM_getUserSaveDirectory(void);
char *FILESYSTEM_getUserLevelDirectory(void); char *FILESYSTEM_getUserLevelDirectory(void);
void FILESYSTEM_mount(const char *fname); void FILESYSTEM_mount(const char *fname);
void FILESYSTEM_loadZip(const char* filename);
extern bool FILESYSTEM_assetsmounted; extern bool FILESYSTEM_assetsmounted;
void FILESYSTEM_mountassets(const char *path); void FILESYSTEM_mountassets(const char *path);
void FILESYSTEM_unmountassets(void); void FILESYSTEM_unmountassets(void);

View file

@ -4,7 +4,6 @@
#include "editor.h" #include "editor.h"
#include <algorithm> #include <algorithm>
#include <physfs.h>
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include <tinyxml2.h> #include <tinyxml2.h>
@ -82,16 +81,7 @@ static void levelZipCallback(const char* filename)
{ {
if (endsWith(filename, ".zip")) if (endsWith(filename, ".zip"))
{ {
PHYSFS_File* zip = PHYSFS_openRead(filename); FILESYSTEM_loadZip(filename);
if (!PHYSFS_mountHandle(zip, filename, "levels", 1))
{
printf(
"Could not mount %s: %s\n",
filename,
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
);
}
} }
} }