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>
8
9#ifdef _WIN32
10 #include <windows.h>
11 #define OS_WINDOWS
12#elif __APPLE__
13 #include <unistd.h>
14 #include <sys/types.h>
15 #include <pwd.h>
16 #define OS_MACOS
17#else
18 #include <unistd.h>
19 #include <sys/types.h>
20 #include <pwd.h>
21 #define OS_LINUX
22#endif
23
24inline std::string
26 std::string appDataDir;
27
28#ifdef OS_WINDOWS
29 const wchar_t* appDataPath = _wgetenv(L"APPDATA");
30 if (appDataPath) {
31 std::filesystem::path winPath = std::filesystem::path(appDataPath);
32 appDataDir = winPath.string();
33 }
34#elif defined(OS_MACOS)
35 const char* homeDir = getenv("HOME");
36 if (homeDir) {
37 appDataDir = std::string(homeDir) + "/Library/Application Support";
38 }
39#else // Linux and other Unix-like systems
40 const char* homeDir = getenv("HOME");
41 if (homeDir) {
42 appDataDir = std::string(homeDir) + "/.local/share";
43 }
44#endif
45
46 return appDataDir;
47}
48
49#endif // APPDATA_UTILS_H
std::string getAppDataDir()
Definition: appDataFoulder.h:25