Libdolfs: Difference between revisions
←Created page with '{{lowercase title}} '''libdolfs''' is a library for accessing a read-only ramdisk (attached to a .dol at compile-time) as though it were a regular filesystem. It provides a c...' |
(No difference)
|
Revision as of 15:10, 28 September 2009
libdolfs is a library for accessing a read-only ramdisk (attached to a .dol at compile-time) as though it were a regular filesystem. It provides a convenient way to include support data with an executable, esp. when porting some code where you don't want to change the underlying core to add an alternative to fread()... or when using psoload without an SD card.
usage and sample code
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");