fs/Traits: add macro PATH_LITERAL()
This commit is contained in:
parent
44565e22a0
commit
39c9669445
@ -66,12 +66,12 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define CONFIG_FILE_LOCATION "mpd\\mpd.conf"
|
||||
#define APP_CONFIG_FILE_LOCATION "conf\\mpd.conf"
|
||||
#define CONFIG_FILE_LOCATION PATH_LITERAL("mpd\\mpd.conf")
|
||||
#define APP_CONFIG_FILE_LOCATION PATH_LITERAL("conf\\mpd.conf")
|
||||
#else
|
||||
#define USER_CONFIG_FILE_LOCATION1 ".mpdconf"
|
||||
#define USER_CONFIG_FILE_LOCATION2 ".mpd/mpd.conf"
|
||||
#define USER_CONFIG_FILE_LOCATION_XDG "mpd/mpd.conf"
|
||||
#define USER_CONFIG_FILE_LOCATION1 PATH_LITERAL(".mpdconf")
|
||||
#define USER_CONFIG_FILE_LOCATION2 PATH_LITERAL(".mpd/mpd.conf")
|
||||
#define USER_CONFIG_FILE_LOCATION_XDG PATH_LITERAL("mpd/mpd.conf")
|
||||
#endif
|
||||
|
||||
static constexpr OptionDef opt_kill(
|
||||
|
@ -174,7 +174,8 @@ LoadPlaylistFileInfo(PlaylistInfo &info,
|
||||
|
||||
const auto *const name_fs_str = name_fs.c_str();
|
||||
const auto *const name_fs_end =
|
||||
FindStringSuffix(name_fs_str, PLAYLIST_FILE_SUFFIX);
|
||||
FindStringSuffix(name_fs_str,
|
||||
PATH_LITERAL(PLAYLIST_FILE_SUFFIX));
|
||||
if (name_fs_end == nullptr)
|
||||
return false;
|
||||
|
||||
|
@ -59,7 +59,8 @@ CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener,
|
||||
if (cache_dir.IsNull())
|
||||
return nullptr;
|
||||
|
||||
const auto db_file = AllocatedPath::Build(cache_dir, "mpd.db");
|
||||
const auto db_file = AllocatedPath::Build(cache_dir,
|
||||
PATH_LITERAL("mpd.db"));
|
||||
const auto db_file_utf8 = db_file.ToUTF8();
|
||||
if (db_file_utf8.empty())
|
||||
return nullptr;
|
||||
|
@ -41,12 +41,12 @@ namespace FOpenMode {
|
||||
/**
|
||||
* Open mode for writing text files.
|
||||
*/
|
||||
constexpr PathTraitsFS::const_pointer WriteText = "w";
|
||||
constexpr PathTraitsFS::const_pointer WriteText = PATH_LITERAL("w");
|
||||
|
||||
/**
|
||||
* Open mode for appending text files.
|
||||
*/
|
||||
constexpr PathTraitsFS::const_pointer AppendText = "a";
|
||||
constexpr PathTraitsFS::const_pointer AppendText = PATH_LITERAL("a");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#define PATH_LITERAL(s) (s)
|
||||
|
||||
/**
|
||||
* This class describes the nature of a native filesystem path.
|
||||
*/
|
||||
@ -48,7 +50,7 @@ struct PathTraitsFS {
|
||||
static constexpr value_type SEPARATOR = '/';
|
||||
#endif
|
||||
|
||||
static constexpr const_pointer CURRENT_DIRECTORY = ".";
|
||||
static constexpr const_pointer CURRENT_DIRECTORY = PATH_LITERAL(".");
|
||||
|
||||
static constexpr bool IsSeparator(value_type ch) {
|
||||
return
|
||||
|
@ -103,7 +103,7 @@ ape_scan_internal(FILE *fp, ApeTagCallback callback)
|
||||
bool
|
||||
tag_ape_scan(Path path_fs, ApeTagCallback callback)
|
||||
{
|
||||
FILE *fp = FOpen(path_fs, "rb");
|
||||
FILE *fp = FOpen(path_fs, PATH_LITERAL("rb"));
|
||||
if (fp == nullptr)
|
||||
return false;
|
||||
|
||||
|
@ -521,7 +521,7 @@ tag_id3_riff_aiff_load(FILE *file)
|
||||
struct id3_tag *
|
||||
tag_id3_load(Path path_fs, Error &error)
|
||||
{
|
||||
FILE *file = FOpen(path_fs, "rb");
|
||||
FILE *file = FOpen(path_fs, PATH_LITERAL("rb"));
|
||||
if (file == nullptr) {
|
||||
error.FormatErrno("Failed to open file %s", path_fs.c_str());
|
||||
return nullptr;
|
||||
|
@ -71,7 +71,7 @@ daemonize_kill(void)
|
||||
if (pidfile.IsNull())
|
||||
FatalError("no pid_file specified in the config file");
|
||||
|
||||
fp = FOpen(pidfile, "r");
|
||||
fp = FOpen(pidfile, PATH_LITERAL("r"));
|
||||
if (fp == nullptr) {
|
||||
const std::string utf8 = pidfile.ToUTF8();
|
||||
FormatFatalSystemError("Unable to open pid file \"%s\"",
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
if (path.IsNull())
|
||||
return;
|
||||
|
||||
file = FOpen(path, "w");
|
||||
file = FOpen(path, FOpenMode::WriteText);
|
||||
if (file == nullptr) {
|
||||
const std::string utf8 = path.ToUTF8();
|
||||
FormatFatalSystemError("Failed to create pid file \"%s\"",
|
||||
|
Loading…
Reference in New Issue
Block a user