SDL_GetCurrentDirectory(3)
β¨ NAME β¨
okay so we're in the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_GetCurrentDirectory β bestie, she gets what the system believes is the "current working directory." π
π¦ SYNOPSIS π¦
#include <SDL3/SDL_filesystem.h>
char * SDL_GetCurrentDirectory(void);
πΈ DESCRIPTION πΈ
so like, some systems literally don't have a concept of a current working directory at all?? π and this function is still gonna attempt to provide something reasonable for you. she tries, okay? she always tries. π«Ά
also important, no cap: SDL does not provide a means to change the current working directory. why? because on platforms without this concept, that would cause surprises with file access outside of SDL. so we're just not doing that. periodt. π
the returned path is guaranteed to end with a path separator β that's '\\' on Windows, and '/' on most other platforms. iconic behavior honestly. β¨
π RETURN VALUE π
- returns a UTF-8 string of the current working directory in platform-dependent notation π
- returns
NULLif there's a problem π (vibe check failed, sorry bestie) - this should be freed with
SDL_free()when it is no longer needed β yes, you have to clean up after yourself, she's not your mom π
π₯ THREAD SAFETY π₯
it is safe to call this function from any thread. go off, multithreaded queen. π
β AVAILABILITY β
this function is available since SDL 3.2.0. so if you're on something older... not her problem, upgrade bestie. π
okay that's the whole page, we ate and left no crumbs π β this was SDL_GetCurrentDirectory(3) from the Simple Directmedia Layer, SDL 3.4.18, dated SDL_GetCurrentDirectory(3). mwah, bye, go free your strings. ππ¦πΈ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms