MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ runtime_directory_candidates()

std::vector< std::filesystem::path > MayaFlux::Platform::runtime_directory_candidates ( )
inlinenodiscard

Per-user directories a Unix socket may live in, in the order tried.

Read from the environment on every call, so a changed variable is seen at once. Linux: XDG_RUNTIME_DIR, then /run/user/<uid>. macOS: TMPDIR. Windows: TEMP, then TMP. Variables that are empty or not absolute are skipped. Nothing here checks that a directory exists.

Definition at line 64 of file UnixSocket.hpp.

65{
66 std::vector<std::filesystem::path> directories;
67
68 const auto add_variable = [&directories](const char* name) {
69 const std::string value = safe_getenv(name);
70 if (value.empty()) {
71 return;
72 }
73 std::filesystem::path directory(value);
74 if (directory.is_absolute()) {
75 directories.push_back(std::move(directory));
76 }
77 };
78
79#if defined(MAYAFLUX_PLATFORM_WINDOWS)
80 add_variable("TEMP");
81 add_variable("TMP");
82#elif defined(MAYAFLUX_PLATFORM_MACOS)
83 add_variable("TMPDIR");
84#else
85 add_variable("XDG_RUNTIME_DIR");
86 directories.emplace_back("/run/user/" + std::to_string(::geteuid()));
87#endif
88
89 return directories;
90}
std::string safe_getenv(const char *var)
Definition Process.hpp:11

References safe_getenv().

Referenced by list_unix_sockets(), and MayaFlux::Platform::detail::resolve_socket_path().

Here is the call graph for this function:
Here is the caller graph for this function: