Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ bool SDL_PhysFS_LoadWAV(const char* filename, SDL_AudioSpec* spec, Uint8** audio
void* SDL_PhysFS_LoadFile(const char* filename, size_t* datasize);
size_t SDL_PhysFS_WriteFile(const char* file, const void* buffer, size_t size);
bool SDL_PhysFS_SetWriteDir(const char* path);
const char* SDL_PhysFS_GetWriteDir(void);
const char* SDL_PhysFS_GetWriteDir();
char** SDL_PhysFS_LoadDirectoryFiles(const char* directory);
bool SDL_PhysFS_EnumerateDirectory(const char* path, SDL_EnumerateDirectoryCallback callback, void* userdata);
void SDL_PhysFS_FreeDirectoryFiles(char** files);
bool SDL_PhysFS_Exists(const char* file);
SDL_IOStatus SDL_PhysFS_IOStatus(int error);
int SDL_PhysFS_GetVersion();

// Optional Integrations
SDL_Surface* SDL_PhysFS_IMG_Load(const char* filename); // SDL_image
Expand Down
18 changes: 17 additions & 1 deletion include/SDL_PhysFS.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* SDL_PhysFS.h v3.1.0 - PhysFS virtual file system support for SDL.
* SDL_PhysFS.h v3.2.1 - PhysFS virtual file system support for SDL.
*
* https://github.com/RobLoach/SDL_PhysFS
*
Expand Down Expand Up @@ -36,10 +36,17 @@
#endif
#endif

#define SDL_PHYSFS_MAJOR_VERSION 3
#define SDL_PHYSFS_MINOR_VERSION 2
#define SDL_PHYSFS_MICRO_VERSION 1
#define SDL_PHYSFS_VERSION SDL_VERSIONNUM(SDL_PHYSFS_MAJOR_VERSION, SDL_PHYSFS_MINOR_VERSION, SDL_PHYSFS_MICRO_VERSION)
#define SDL_PHYSFS_VERSION_ATLEAST(X, Y, Z) (SDL_PHYSFS_VERSION >= SDL_VERSIONNUM(X, Y, Z))

#ifdef __cplusplus
extern "C" {
#endif

SDL_PHYSFS_DEF int SDL_PhysFS_GetVersion(void);
SDL_PHYSFS_DEF bool SDL_PhysFS_Init(const char* argv);
SDL_PHYSFS_DEF bool SDL_PhysFS_InitEx(const char* argv, const char* org, const char* app);
SDL_PHYSFS_DEF bool SDL_PhysFS_Quit();
Expand Down Expand Up @@ -183,6 +190,15 @@ static void SDL_PhysFS_AllocatorFree(void* mem) {
return free_func(mem);
}

/**
* Get the version of SDL_PhysFS that is linked against your program.
*
* @return Returns the version of the linked library.
*/
int SDL_PhysFS_GetVersion(void) {
return SDL_PHYSFS_VERSION;
}

/**
* Initialize the PhysFS virtual file system.
*
Expand Down
3 changes: 3 additions & 0 deletions test/SDL_PhysFS_Test.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ int main(int argc, char* argv[]) {
SDL_assert(SDL_PhysFS_Exists("res/test.bmp") == true);
SDL_assert(SDL_PhysFS_Exists("res/notfound.txt") == false);

// SDL_PhysFS_GetVersion
SDL_assert(SDL_PhysFS_GetVersion() > 2);

// SDL_PhysFS_LoadDirectoryFiles
{
char** files = SDL_PhysFS_LoadDirectoryFiles("res");
Expand Down