A single-header C++17+ library for retrieving cross-platform application directories such as config, cache, data, and log folders. Supports Windows, macOS, Linux, Android (via JNI), and iOS (via Foundation).
- Cross-platform: Windows, macOS, Linux, Android, iOS
- Clean
std::filesystem::pathAPI - Header-only, zero external dependencies
- Supports app-specific folder resolution
- JNI and Objective-C++ hooks for mobile
#include "platform_dirs.hpp"
auto config_path = platform_dirs::get_app_dir("MyApp");You must call platform_dirs::init() with the JNI context before using get_app_dir():
extern "C" JNIEXPORT void JNICALL
Java_com_example_MainActivity_init(JNIEnv* env, jobject ctx) {
platform_dirs::init(env, ctx);
}Include the file in an Objective-C++ (.mm) file if using iOS.
get_app_dir(app_name)get_config_dir(app_name)get_cache_dir(app_name)get_data_dir(app_name)get_log_dir(app_name)get_temp_dir()(no app name needed)
- Falls back to
$HOME/.configor platform-specific conventions - Uses
getenv()for desktop env vars - Android and iOS use system APIs via JNI and Foundation respectively
- Returns empty path or
/tmpif fallback is needed
No build system needed — just include the header. For CMake:
target_include_directories(your_target PRIVATE vendor/PlatformDirs/include)Licensed under GPLv3