From 9e4076a418b3ee771438ad757f28b947345074bb Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 4 Mar 2021 16:45:07 -0800 Subject: [PATCH] Add FILESYSTEM_isMounted() This returns if the file given is mounted or not. 2.3 added level zip support, so whenever the game loads level metadata, it will mount any zip files in the levels directory; this function can be used to check if any of those files have been mounted, and ignore them if so. --- desktop_version/src/FileSystemUtils.cpp | 5 +++++ desktop_version/src/FileSystemUtils.h | 1 + 2 files changed, 6 insertions(+) diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 1a340f02..2ff8360d 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -186,6 +186,11 @@ bool FILESYSTEM_isFile(const char* filename) || stat.filetype == PHYSFS_FILETYPE_SYMLINK; } +bool FILESYSTEM_isMounted(const char* filename) +{ + return PHYSFS_getMountPoint(filename) != NULL; +} + static bool FILESYSTEM_exists(const char *fname) { return PHYSFS_exists(fname); diff --git a/desktop_version/src/FileSystemUtils.h b/desktop_version/src/FileSystemUtils.h index ddd163aa..f3aee2e3 100644 --- a/desktop_version/src/FileSystemUtils.h +++ b/desktop_version/src/FileSystemUtils.h @@ -13,6 +13,7 @@ char *FILESYSTEM_getUserSaveDirectory(void); char *FILESYSTEM_getUserLevelDirectory(void); bool FILESYSTEM_isFile(const char* filename); +bool FILESYSTEM_isMounted(const char* filename); void FILESYSTEM_mount(const char *fname); void FILESYSTEM_loadZip(const char* filename);