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)
(want the best & it must be 100% free)…
Our application is on GitHub below(it’s a VERY early alpha that does not do much):
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…
I simply call the appropriate functions in the C runtime (
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.
Cool, I’ll try C runtime functions…
Also, I use CodeBlocks on Windows® & a makefile on Linux, so should be fine…
Might I also suggest PhysFS, which is also worked on by Ryan Gordon.
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:
It shouldn’t be that difficult to do?
I agree it would be nice. You omitted
SDL_chdir from the list, and
SDL_findnext don’t map very well to the Linux way of doing things (when would SDL call
SDL_closedir would be a better fit (
SDL_closedir could be a NOP in Windows).
I second the notion that SDL should have more cross-platform file system capabilities.
That was intentional. I could live without chdir and just navigate around by supplying relative paths based off
SDL_GetPrefPath which would be a safer approach maybe?
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.
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.