config/Path: use string_view literals
This commit is contained in:
parent
e8ce417150
commit
6fd6a5110c
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
using std::string_view_literals::operator""sv;
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
|
||||||
@ -98,15 +100,15 @@ ParsePath(const char *path)
|
|||||||
const auto [env_var, rest] = Split(std::string_view{path}, '/');
|
const auto [env_var, rest] = Split(std::string_view{path}, '/');
|
||||||
|
|
||||||
AllocatedPath xdg_path(nullptr);
|
AllocatedPath xdg_path(nullptr);
|
||||||
if (env_var == "HOME") {
|
if (env_var == "HOME"sv) {
|
||||||
xdg_path = GetConfiguredHome();
|
xdg_path = GetConfiguredHome();
|
||||||
} else if (env_var == "XDG_CONFIG_HOME") {
|
} else if (env_var == "XDG_CONFIG_HOME"sv) {
|
||||||
xdg_path = GetUserConfigDir();
|
xdg_path = GetUserConfigDir();
|
||||||
} else if (env_var == "XDG_MUSIC_DIR") {
|
} else if (env_var == "XDG_MUSIC_DIR"sv) {
|
||||||
xdg_path = GetUserMusicDir();
|
xdg_path = GetUserMusicDir();
|
||||||
} else if (env_var == "XDG_CACHE_HOME") {
|
} else if (env_var == "XDG_CACHE_HOME"sv) {
|
||||||
xdg_path = GetUserCacheDir();
|
xdg_path = GetUserCacheDir();
|
||||||
} else if (env_var == "XDG_RUNTIME_DIR") {
|
} else if (env_var == "XDG_RUNTIME_DIR"sv) {
|
||||||
xdg_path = GetUserRuntimeDir();
|
xdg_path = GetUserRuntimeDir();
|
||||||
} else {
|
} else {
|
||||||
throw FmtRuntimeError("environment variable not supported: {:?}", env_var);
|
throw FmtRuntimeError("environment variable not supported: {:?}", env_var);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user