|
[Help]Using Physfs for DataFiles |
variancegears
Member #23,382
June 2022
|
Hi, I am using allegro5 and am trying to implement Physfs for datafiles but I do not know where to start or how to initiate it. Is there a basic snippet of code for reference anywhere on this? I am trying to use it on some .wav files and what not but have no idea where to start. thanks |
Todd Cope
Member #998
November 2000
|
Before interacting with your "datafile" (which is just a ZIP file containing your files), you'll need to set up PhysFS and Allegro's PhysFS file interface. 1#include <allegro5/allegro_physfs.h>
2#include <physfs.h>
3
4...
5
6/* you'll have to get argv[0] from main to this call somehow */
7if(PHYSFS_init(argv[0]))
8{
9 if(PHYSFS_addToSearchPath("datatile.zip", 1)
10 {
11 /* remember old file interface */
12 al_store_state(&old_state, ALLEGRO_STATE_NEW_FILE_INTERFACE);
13 al_set_physfs_file_interface();
14 mysample = al_load_sample("sample.wav");
15 ...
16 /* restore old file interface when we are done accessing our datafile */
17 al_restore_state(&old_state);
18 }
19}
|
|