From 43692388c01c1c489e02506994785b4a0f515d59 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 3 Apr 2021 14:07:51 -0700 Subject: [PATCH] Use FILESYSTEM_mount() when mounting zips There's no reason to handle mounting .zip files differently than mounting a directory... we already mount .data.zip files using FILESYSTEM_mount(), so why go through the trouble of opening a .zip manually (which means on Windows the .zip can't be touched for the duration of playing the custom level), making up a place to mount it at, and then mount that made-up name, instead of just using FILESYSTEM_mount()? Whoever cobbled this asset mounting thing together really didn't fully understand what they were doing. --- desktop_version/src/FileSystemUtils.cpp | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 8d4f58f4..1e95d399 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -307,35 +307,12 @@ void FILESYSTEM_mountAssets(const char* path) } else if (zip_normal != NULL && endsWith(zip_normal, ".zip")) { - PHYSFS_File* zip = PHYSFS_openRead(zip_normal); - printf("Custom asset directory is .zip at %s\n", zip_normal); - SDL_snprintf( - zip_data, - sizeof(zip_data), - "%s.data.zip", - zip_normal - ); - - if (zip == NULL) + if (!FILESYSTEM_mount(zip_normal)) { - printf( - "Error loading .zip: %s\n", - PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()) - ); return; } - if (PHYSFS_mountHandle(zip, zip_data, "/", 0) == 0) - { - printf( - "Error mounting .zip: %s\n", - PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()) - ); - return; - } - - SDL_strlcpy(assetDir, zip_data, sizeof(assetDir)); graphics.reloadresources(); }