Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » PhysFS_mount()

This thread is locked; no one can reply to it. rss feed Print
PhysFS_mount()
SpectreNectar
Member #10,969
May 2009
avatar

I'm trying to write to a file (again) while using PhysFS.

How to use al_fputc() for instance, without switching to the standard file interface?

I have mounted the "./" directory as root. I'm not even sure if that's allowed, hehe. Not that I'd have any experience stringing absolute paths together with the lib.

main.cpp

al_set_physfs_file_interface();

    /* Set up PhysicsFS. */
    if(!PHYSFS_init(0)) std::cout << "failed initializing" << std::endl;
    // This creates a ~/.allegro directory, which is very annoying to say the
    // least - and no need for it in this example.
    //  if (!PHYSFS_setSaneConfig("allegro", "ex_physfs", NULL, 0, 0))
    //     return 1;
    else if(!PHYSFS_addToSearchPath("data", 1)
         || !PHYSFS_addToSearchPath("shaders", 1)) std::cout << "failed adding search path" << std::endl;
    else if(!PHYSFS_mount("./", "", 1)) std::cout << "failed mounting file path" << std::endl;

writer.cpp

#SelectExpand
1Writer::Writer(const char* filename) { 2 3 4 //al_set_standard_file_interface(); 5 6 file = al_fopen(filename, "wb"); 7 8} 9 10 11Writer::~Writer() { 12 13 al_fclose(file); 14 15 //al_set_physfs_file_interface(); 16 17} 18 19 20void Writer::write_big3(int dat) { 21 22 al_fputc(file, (dat/(256*256))%256); 23 al_fputc(file, (dat/256)%256); 24 al_fputc(file, dat%256); 25 26}

Writer testwriter("sheep.txt");
testwriter.write_big3(70000); //Crash

I get Assertion failed: f, file d:\Libraries\build\allegro\src\allegro-5.0.x\allegro-5.0.x\src\file.c, line 208

I realize it's an old Allegro build.

Thanks! :)

Go to: