johannes-fetz / joengine

Jo Engine is an open source 2D and 3D game engine for the Sega Saturn written in C under MIT license
http://jo-engine.org/
MIT License
201 stars 31 forks source link

backup: BUP_Dir() Support #33

Closed slinga-homebrew closed 4 years ago

slinga-homebrew commented 4 years ago

Hi Johannes,

For my newest project I am making use of Jo Engine's backup functions. I would like to request the addition of a wrapper to BUP_Dir() so I can list the saves on the backup medium.

BUP_Dir's prototype is: Sint32 BUP_Dir(Uint32 device,Uint8 fname,Uint16 dirsize, BupDir dir). On success the dir array is filled out a list of filenames on the save medium. Thanks in advance.

johannes-fetz commented 4 years ago

Ok, I will check that

johannes-fetz commented 4 years ago
  USAGE:

    jo_list filenames;
    jo_list_init(&filenames);
    jo_backup_read_device(dev, &filenames);

    //Number of files : filenames.count
    //Get filename : jo_list_at(&filenames, 0)->data.ch_arr or filenames.first->data.ch_arr
    // You can also use jo_list_foreach

    // Don't forger to free :)
    jo_list_free_and_clear(&filenames);
slinga-homebrew commented 4 years ago

Hi Johannes,

Thank you for implementing this functionality. I noticed that this code was not finding any saves. I traced the issue to:

JO_BACKUP_DRIVER_GET_FILE_INFO(backup_device, JO_NULL, JO_BACKUP_MAX_FILE, dir);

which should be:

JO_BACKUP_DRIVER_GET_FILE_INFO(backup_device, "", JO_BACKUP_MAX_FILE, dir);

Once I made that change my code starting working. I tried to make a PR but I hate GIT.