AYON Cpp Api  0.1.0
Loading...
Searching...
No Matches
appDataFoulder.h
Go to the documentation of this file.
1#ifndef APPDATA_UTILS_H
2#define APPDATA_UTILS_H
3
4#include <string>
5#include <cstdlib>
6#include <filesystem>
7
8#ifdef _WIN32
9 #include <windows.h>
10 #define OS_WINDOWS
11#elif __APPLE__
12 #include <unistd.h>
13 #include <sys/types.h>
14 #include <pwd.h>
15 #define OS_MACOS
16#else
17 #include <unistd.h>
18 #include <sys/types.h>
19 #include <pwd.h>
20 #define OS_LINUX
21#endif
22
23inline std::string
25 std::string appDataDir;
26
27#ifdef OS_WINDOWS
28 const wchar_t* appDataPath = _wgetenv(L"APPDATA");
29 if (appDataPath) {
30 std::filesystem::path winPath = std::filesystem::path(appDataPath);
31 appDataDir = winPath.string();
32 }
33#elif defined(OS_MACOS)
34 const char* homeDir = getenv("HOME");
35 if (homeDir) {
36 appDataDir = std::string(homeDir) + "/Library/Application Support";
37 }
38#else // Linux and other Unix-like systems
39 const char* homeDir = getenv("HOME");
40 if (homeDir) {
41 appDataDir = std::string(homeDir) + "/.local/share";
42 }
43#endif
44
45 return appDataDir;
46}
47
48#endif // APPDATA_UTILS_H
std::string getAppDataDir()
Definition: appDataFoulder.h:24