icculus / physfs

A portable, flexible file i/o abstraction.
https://icculus.org/physfs/
zlib License
560 stars 98 forks source link

Your archive format #50

Closed Quarnion closed 2 years ago

Quarnion commented 2 years ago

Hello, I would like to clarify whether it is possible to create your own archive format using the library?

If so, could you briefly explain what procedures need to be performed?

Quarnion commented 2 years ago

I read about _PHYSFSArchiver but did not understand anything :(

Green-Sky commented 2 years ago

roughly speaking, you need to provide all the functions for your archive type. i did this some years ago to load stringliterals (static c strings) as files. https://github.com/MadeOfJelly/MushMachine/blob/master/framework/filesystem/src/mm/fs_const_archiver.hpp (and .cpp in the same folder)

code is very hacky, you have been warned! :)

edit: here i fake a mount, because i don't have a real archive https://github.com/MadeOfJelly/MushMachine/blob/master/framework/filesystem/src/mm/services/filesystem.cpp#L80-L88

icculus commented 2 years ago

(Closing this because it's not a bug, but also: yes, you can provide your own archive format to PhysicsFS by supplying function pointers from your app without modifying PhysicsFS source code directly...but if it's a reasonably standard or popular format, it makes sense to just slot it into PhysicsFS's sources for others to use, too. Either approach is totally okay.)