Suggestion: file system functionalities

First time post here, please tell me if I go against some rules. I have checked if my question isn’t already there and haven’t seen it.

SDL already has great file abstraction functionality, but what I am missing is the ability to enumerate the files in a directory, and more specifically, get modified date/time of files. I know how to write it for Linux and Windows but it would be much better if SDL offered this functionality.

Why do I want/need this? Because I want to support modding with Lua scripts on my game: the scripts should be found automatically by the game and when loaded, the game should be able to detect if the file has changed (modified date/time) so that the Lua script can be reloaded and the game doesn’t need to be restarted or the user doesn’t have to manually reload the mod. When the mod contains a syntax error, the script will be disabled until the file is modified and automatically reloaded.

Any chance this will be implemented?


I agree with you,we can need more functional like this。

There is a (very old) related thread.

If you’re programming with C++, C++ 17 comes with a filesystem library. The major benefit is that it’s platform agnostic and spares you from rewriting to fit the target system.

After more than 20 years of C++ programming, I left it for plain good old C early this year and rewrote my game engine completely. I haven’t regretted it once :slight_smile:

Anyway: I hope to see an answer from the SDL developers on my original question: Any chance this will be implemented?

Well, I guess that’s what the “YMMV” is for I guess :smiley:

Sorry… what is the “YMMV”? This may be a very stupid question but I’m new here :slight_smile:

YMMV means “Your Mileage May Vary”, commonly used in forums to indicate the author is aware results may vary from person to person, for instance :slight_smile:

1 Like

I have the opposite view. There are tons of libraries out there for this sort of thing, or built into later versions of C++ but the core graphics rendering and audio functionality of SDL in a cross platform library is harder to find.

I think the developers should focus on the core SDL rather than spend time on things like this.

I have some sympathy with that view, especially if development resources are limited, but on the other hand SDL2 claims to be much more than just a graphics and audio library. At the API By Category page it lists Threads, Timers, File Abstraction, Shared Object Support and more as features of SDL2

One omission which I would like to see put right is the ability to modify the length of a file, particularly to truncate it. Although SDL provides for modifying or extending an existing file, truncating it is notable by its absence.

And I no longer thrust most of these libraries. They are usually bloated, badly written, too complicated to use, buggy, dependent on other badly written libraries, … you name it. It’s actually one of the reasons I went back to C (from C++). These pages are very inspiring: Suckless and Why I Write Games in C (all to be read with a grain of salt of course)

SDL is one of the few libraries I thrust enough to use it. I have used my own cross-platform library for years but I must admit that SDL is better and gives me more time to spend on writing games instead of maintaining my own. It has an 80’s view on coding I can very much appreciate. I think SDL offers lots of cross-platform features without trying to be a real game engine like for example buggy Unity. Unlike a 3D engine or something else forcing you into specific directions, more file system features would fit right in. I think basic networking features would also be a great addition, still low level enough to not force users into specific paths but cross platform enough to work everywhere.

Anyway, it’s up to the developers. Without it, I will still be able to get it to work on my release platforms if I ever get that far, but it would be nice to have it work without worries.



Did you had a look at Ryan Gordon’s PhysicsFS library? I use it for all
my SDL projects to handle filesystem related stuff. It’s located at

There is an API related to file date and time:

And for linking with SDL, you’ll find in the source extras/ directory
the physfsrwops.c file that creates SDL_RWOps stuff specifically for use
with PhysicsFS.

This looks very interesting! Up until now, I always implemented zip packs myself.
However, I find stuff like support for all kinds of not widely used filetypes (Gothic, Independence War) feel like bloat. This may be just a very small addition, so I will look into it!