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 NULL if 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