fs/StandardDirectory: add GetAppRuntimeDir()
This commit is contained in:
parent
1e6f5f012c
commit
b9f7127691
@ -86,13 +86,10 @@ ListenXdgRuntimeDir(ClientListener &listener) noexcept
|
|||||||
use $XDG_RUNTIME_DIR */
|
use $XDG_RUNTIME_DIR */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto xdg_runtime_dir = GetUserRuntimeDir();
|
const auto mpd_runtime_dir = GetAppRuntimeDir();
|
||||||
if (xdg_runtime_dir.IsNull())
|
if (mpd_runtime_dir.IsNull())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto mpd_runtime_dir = xdg_runtime_dir / Path::FromFS("mpd");
|
|
||||||
mkdir(mpd_runtime_dir.c_str(), 0700);
|
|
||||||
|
|
||||||
const auto socket_path = mpd_runtime_dir / Path::FromFS("socket");
|
const auto socket_path = mpd_runtime_dir / Path::FromFS("socket");
|
||||||
unlink(socket_path.c_str());
|
unlink(socket_path.c_str());
|
||||||
|
|
||||||
|
@ -292,6 +292,20 @@ GetUserRuntimeDir() noexcept
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AllocatedPath
|
||||||
|
GetAppRuntimeDir() noexcept
|
||||||
|
{
|
||||||
|
#ifdef USE_XDG
|
||||||
|
if (const auto user_dir = GetUserRuntimeDir(); !user_dir.IsNull()) {
|
||||||
|
auto dir = user_dir / Path::FromFS("mpd");
|
||||||
|
mkdir(dir.c_str(), 0700);
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
AllocatedPath
|
AllocatedPath
|
||||||
|
@ -50,6 +50,13 @@ GetUserCacheDir() noexcept;
|
|||||||
AllocatedPath
|
AllocatedPath
|
||||||
GetUserRuntimeDir() noexcept;
|
GetUserRuntimeDir() noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains the runtime directory for this application.
|
||||||
|
*/
|
||||||
|
[[gnu::const]]
|
||||||
|
AllocatedPath
|
||||||
|
GetAppRuntimeDir() noexcept;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user