mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-10-05 05:42:18 +00:00
[vfs #1] Add ttvfs, miniz, and minihttp sources
This commit is contained in:
parent
99e3f5ebe2
commit
a90f57afb0
36 changed files with 10047 additions and 0 deletions
68
ExternalLibs/ttvfs/VFSArchiveLoader.h
Normal file
68
ExternalLibs/ttvfs/VFSArchiveLoader.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
#ifndef VFS_ARCHIVE_LOADER_H
|
||||
#define VFS_ARCHIVE_LOADER_H
|
||||
|
||||
#include "VFSDefines.h"
|
||||
|
||||
VFS_NAMESPACE_START
|
||||
|
||||
class VFSDir;
|
||||
class VFSFile;
|
||||
class VFSLoader;
|
||||
|
||||
// Generic Archive loader interface that is supposed to return a valid VFSDir pointer when it
|
||||
// was able to load 'arch' as an archive, and NULL if there was an error or the loader is
|
||||
// unable to load that file type.
|
||||
// 'asSubdir' - if this is true, the archive will be accessible as a folder (as in "test.zip/file.dat"),
|
||||
// otherwise the files are mounted in place of the archive.
|
||||
// 'ldr' - can be set to an external file loader in case the file/folder tree can not be fully generated
|
||||
// at load time.
|
||||
// 'opaque' - a POD struct which *must* have a `void (*)(void*, void*, const char*)`
|
||||
// function pointer as first member (at offset 0).
|
||||
// The struct pointer is then passed to that function, along with a pointer to an internal object,
|
||||
// whatever this is. The derived loader knows what this object is - something that this callback
|
||||
// will be interested in modifying, anyways. The rest of the struct can carry the data required to
|
||||
// modify this object.
|
||||
// The const char parameter is a string unique for each loader (to prevent accessing the pointer
|
||||
// in a wrong way by the wrong loader). Example below.
|
||||
class VFSArchiveLoader
|
||||
{
|
||||
public:
|
||||
virtual ~VFSArchiveLoader() {}
|
||||
|
||||
virtual VFSDir *Load(VFSFile *arch, VFSLoader **ldr, void *opaque = NULL) = 0;
|
||||
};
|
||||
|
||||
/* A possible struct for 'opaque' would be:
|
||||
|
||||
struct ExampleLoadParams
|
||||
{
|
||||
void (*callback)(void *, void *, const char *);
|
||||
const char *key;
|
||||
unsigned int keylen;
|
||||
};
|
||||
|
||||
And then the call would look like:
|
||||
(Assuming PakFile is an archive file class that represents an archive)
|
||||
|
||||
void pakSetup(void *data, void *arch, const char *id)
|
||||
{
|
||||
if(strcmp(id, "pak")) // Be sure we're in the right loader.
|
||||
return;
|
||||
ExampleLoadParams *pm = (ExampleLoadParams*)p;
|
||||
PakArchive *pak = (PakArchive*)arch;
|
||||
pak->SetKey(pm->key, pm->keylen);
|
||||
}
|
||||
|
||||
ExampleLoadParams p;
|
||||
p.callback = &pakSetup;
|
||||
p.key = "123456";
|
||||
p.keylen = 6;
|
||||
vfs.AddArchive("data.pak", false, "", &p);
|
||||
|
||||
Where p in turn will be passed to the PAK loader.
|
||||
|
||||
*/
|
||||
|
||||
VFS_NAMESPACE_END
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue