Attached is the code for libdolfs - a read-only ramdisk which is attached at compile-time to your .dol. It's a lot like using bin2o to add binary data to the executable, but this library uses the Newlib devoptab structs to let you then access the data like any attached filesystem using fopen(), fread(), etc.
This software is in the public domain.
No idea how useful this will be. In my case I'm porting an emulator that reads a config file at start-up, and I don't want to change the emu code... since all my work is done through psoload, I can't add support files to an SD card. Hence this solution.
This initial release does not support directory access, but does allow long filenames.
Usage:
* first, build the library for your target system. Edit the makefile in dolfs/libdolfs and uncomment the SYSTARGET line to match your system (gamecube or wii). Run "make" then "make install". The library and include are copied to your libogc/ installation.
* next you need the tool to make a ramdisk. Run "make" in dolfs/ to build dfspack. Note: this requires a working c++ compiler on your system...
* Now you can use dfspack to build a ramdisk. Make a directory, fill it with files, then from the directory above:
dfspack <directory> <ramdiskname>
This will put all the files in <directory> into a single file, <ramdiskname>.h.
* #include "<ramdiskname>.h" at the top of your main source file
* mount the ramdisk with dolfsInit(&<ramdiskname>);
* read files from the ramdisk by prefix the path with <ramdiskname>: e.g.
FILE *cfgfile = fopen("ramdisk:/config.h","r");
Good luck! Send bug reports to
kennedy.greg@gmail.com