SDL2 - Recommendations For Best Cross-Platform File System IO Library?[SOLVED]


#1

Hi,

Working on an SDL2 application which will run on Windows® and Linux.
I am at a point where I need a cross-platform file system IO library which works with SDL2.
Need file system navigation with directory listing and folder/file creation/deletion.
(again, must work on both Windows® and Linux)

Any recommendations?
(want the best & it must be 100% free)…

Thanks!

Jesse

Our application is on GitHub below(it’s a VERY early alpha that does not do much):


#2

Hi. just try C++17 or boost::filesystem (https://en.cppreference.com/w/cpp/experimental/fs).
I want to notice that this question has nothing to do with the development of the SDL…


#3

I simply call the appropriate functions in the C runtime (chdir, mkdir, rmdir, readdir and so on), they work on all the platforms I support (Windows, Linux, MacOS, Android, iOS). As noted in another thread, you may need to use MinGW or Cygwin (not Visual Studio) if you want to call them on Windows.


#4

Hi,

Cool, I’ll try C runtime functions…
Also, I use CodeBlocks on Windows® & a makefile on Linux, so should be fine…

Thanks!

Jesse


#5

Might I also suggest PhysFS, which is also worked on by Ryan Gordon.


#6

I had to move from MinGW to VC++ so I could use Steam’s API, which doesn’t support MinGW.

All we need for SDL to have it’s own complete cross-platform system is:

SDL_delete
SDL_mkdir
SDL_rmdir
SDL_rename
SDL_findfirst
SDL_findnext

It shouldn’t be that difficult to do?


#7

I agree it would be nice. You omitted SDL_chdir from the list, and SDL_findfirst / SDL_findnext don’t map very well to the Linux way of doing things (when would SDL call closedir?). Possibly SDL_opendir, SDL_readdir and SDL_closedir would be a better fit (SDL_closedir could be a NOP in Windows).


#8

I second the notion that SDL should have more cross-platform file system capabilities.


#9

That was intentional. I could live without chdir and just navigate around by supplying relative paths based off SDL_GetBasePath, and SDL_GetPrefPath which would be a safer approach maybe?


#10

It’s a fair point: chdir doesn’t have much of a meaning on Android. I think we need SDL_GetTempPath in addition to those others, to have somewhere to put temporary files.


#11

boost::filesystem only crashed and corrupted memory of mine, and (as usual) StackOverflow whined and didn’t bother to help, so I had to resort to making my own library.

It ended up being not as hard as I originally thought (though obviously not super-portable, it’s UNIX & Windows only.