Skip to content

Commit 3c4ca57

Browse files
StellaSmithmika314
authored andcommitted
add SDL_GetBasePath wrapper
1 parent bd37a1d commit 3c4ca57

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sdlpp.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ SOFTWARE.
3131
#ifdef USE_SDLGFX
3232
#include <SDL2_gfxPrimitives.h>
3333
#endif
34+
#include <filesystem>
3435
#include <functional>
3536
#include <sstream>
3637

@@ -577,4 +578,12 @@ namespace sdl
577578
}
578579
}
579580
};
581+
582+
std::filesystem::path get_base_path()
583+
{
584+
using deleter = decltype([](void *ptr) { SDL_free(ptr); });
585+
auto ptr = std::unique_ptr<char[], deleter>(SDL_GetBasePath());
586+
return std::filesystem::path(reinterpret_cast<char8_t const *>(ptr.get()),
587+
std::filesystem::path::native_format);
588+
}
580589
} // namespace sdl

0 commit comments

Comments
 (0)