Giter Club home page Giter Club logo

miniphysfs's Introduction

MiniPhysFS

This is the PhysFS contained in a single header to be bundled in C/C++ applications with ease. PhysFS is a library to provide abstract access to various archives.

Example Usage

#define PHYSFS_IMPL
#define PHYSFS_PLATFORM_IMPL
#define PHYSFS_SUPPORTS_ONLY_ZIP
#include "miniphysfs.h"

int main(int argc, char **argv) {
    if(!PHYSFS_init(argv[0])) {
        printf("PhysFS initialization failed: %s\n", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
        return -1;
    }
    /* your PhysFS logic here */
    PHYSFS_deinit();
    return 0;
}

Usage

MiniPhysFS do very little modification to the original library, the PhysFS sources were concatenated to a single C header and some defines were added to make easy of use.

To use the header do this

#define PHYSFS_IMPL
#define PHYSFS_PLATFORM_IMPL

before you include this file in one C file to create the implementation.

On MacOS you need to define PHYSFS_PLATFORM_IMPL in a separate a .m file. And on Haiku or WinRT you need to define PHYSFS_PLATFORM_IMPL in a separate .cpp file.

Note that almost no modification was made in the PhysFS implementation code, thus there are some C variable names that may collide with your code, therefore it is best to declare the PhysFS implementation in dedicated C file.

By default all archives are supported, you can disable any of them by defining:

PHYSFS_SUPPORTS_NO_ZIP
PHYSFS_SUPPORTS_NO_7Z
PHYSFS_SUPPORTS_NO_GRP
PHYSFS_SUPPORTS_NO_WAD
PHYSFS_SUPPORTS_NO_HOG
PHYSFS_SUPPORTS_NO_MVL
PHYSFS_SUPPORTS_NO_QPAK
PHYSFS_SUPPORTS_NO_SLB
PHYSFS_SUPPORTS_NO_ISO9660
PHYSFS_SUPPORTS_NO_VDF

Or you can request only certain archives to be supported by defining one of these:

PHYSFS_SUPPORTS_ONLY_ZIP
PHYSFS_SUPPORTS_ONLY_7Z
PHYSFS_SUPPORTS_ONLY_GRP
PHYSFS_SUPPORTS_ONLY_WAD
PHYSFS_SUPPORTS_ONLY_HOG
PHYSFS_SUPPORTS_ONLY_MVL
PHYSFS_SUPPORTS_ONLY_QPAK
PHYSFS_SUPPORTS_ONLY_SLB
PHYSFS_SUPPORTS_ONLY_ISO9660
PHYSFS_SUPPORTS_ONLY_VDF

Optionally provide the following defines with your own implementations:

  • PHYSFS_DECL - public function declaration prefix (default: extern)

Documentation

For documentation on how to use PhysFS read the header or its official documentation.

Updates

  • 07-May-2021: Updated to PhysFS changeset e0346f434926, for better ARM64 support.
  • 20-Nov-2020: Library created, using PhysFS changeset acdcf93d1f9b

Notes

PhysFS 3.1.0 with latest changeset (as 20-Nov-2020) acdcf93d1f9b was used to make this library, the PhysFS 3.1.0 is not officially released yet, but this changeset was chosen due to the added support for Android.

License

Same license as PhysFS, zlib license, see LICENSE.txt for licensing information.

miniphysfs's People

Contributors

edubart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

miniphysfs's Issues

Mac build: Do not use X directly

Hey!

I'm trying to get this working for linux/win/mac, when I get to the mac build, I set up a .c file for the implementation and a .m file for the platform implementation and feed that to clang c compiler.

I'm getting errors because of that

miniphysfs/miniphysfs.h

Lines 4291 to 4295 in 2191557

/* Use the allocation hooks. */
#define malloc(x) Do not use malloc() directly.
#define realloc(x, y) Do not use realloc() directly.
#define free(x) Do not use free() directly.
/* !!! FIXME: add alloca check here. */

What is this? Is the mac support incomplete?

Mac help

Pardon me, if this is dumb, as I am not great with C, but I can't build on Mac.

I'm pretty sure I don't understand the instructions (put what code in .m file?) I saw #1 but I still don't get it. Here is what I did:

#define PHYSFS_IMPL
#define PHYSFS_PLATFORM_IMPL
#define PHYSFS_SUPPORTS_ONLY_ZIP
#include "miniphysfs.h"

I get this error:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:8:
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:523:1: error: expected identifier or '('
@class NSString, Protocol;

and a bunch more that are similar.

I am trying to just compile a plain C program that runs on mac/win/linux but .m files are ObjectiveC, right?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.