Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rcore] Virtual File System callbacks/macros required #4551

Open
4 tasks done
konsumer opened this issue Nov 28, 2024 · 0 comments
Open
4 tasks done

[rcore] Virtual File System callbacks/macros required #4551

konsumer opened this issue Nov 28, 2024 · 0 comments
Labels
enhancement This is an improvement of some feature

Comments

@konsumer
Copy link

konsumer commented Nov 28, 2024

  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • I checked the documentation on the wiki
  • My code has no errors or misuse of raylib

Issue description

As-per discussion here the filesystem callbacks are useful and work great, when trying to implement a virtual filesystem (I am using physfs), but there are still some functions without hooks or macros that need to some way to be overwritten:

FileExists
DirectoryExists
GetFileLength
ChangeDirectory
IsPathFile
LoadDirectoryFiles
LoadDirectoryFilesEx
GetFileModTime

I made a little library here and just added FS to the end of the names, to prevent collision. Also @RobLoach made raylib-physfs, which doesn't use callbacks, but takes a similar naming-approach.

I think either a macro or the callback-system are fine, I just need a way to overwrite these, so when the user calls FileExists it calls PHYSFS_stat.

I am happy to PR for a macro or callback, whatever everyone thinks is better.

Code Example

It might look like either of these:

bool FileExistsPhysFS(const char *fileName) {
    PHYSFS_Stat stat;
    if (!PHYSFS_stat(fileName, &stat)) return false;
    return stat.filetype == PHYSFS_FILETYPE_REGULAR;
}

// later
SetFileExistsCallback(FileExistsPhysFS);

// OR

#define RL_FS_FILE_EXISTS FileExistsPhysFS
@konsumer konsumer changed the title [module] Short description of the issue/bug/feature callbacks/macros for implementing virtual FS Nov 28, 2024
@raysan5 raysan5 changed the title callbacks/macros for implementing virtual FS [rcore] Virtual File System callbacks/macros required Nov 28, 2024
@raysan5 raysan5 added the enhancement This is an improvement of some feature label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an improvement of some feature
Projects
None yet
Development

No branches or pull requests

2 participants