diff options
author | Max Kellermann <max@duempel.org> | 2014-01-30 20:29:48 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-30 20:39:40 +0100 |
commit | 4465e2c46bbed438377dc4a99df333bd5c058d5e (patch) | |
tree | cbc1d27aad939689f44b0ac3542a6ca1777b9dc1 /src/Mapper.cxx | |
parent | 34b309b99aa2f274308f19974c428e1c7ac5d66f (diff) | |
download | mpd-4465e2c46bbed438377dc4a99df333bd5c058d5e.tar.gz mpd-4465e2c46bbed438377dc4a99df333bd5c058d5e.tar.xz mpd-4465e2c46bbed438377dc4a99df333bd5c058d5e.zip |
db: add compile-time option to disable database
Diffstat (limited to 'src/Mapper.cxx')
-rw-r--r-- | src/Mapper.cxx | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/Mapper.cxx b/src/Mapper.cxx index ebcab91bf..8d9544932 100644 --- a/src/Mapper.cxx +++ b/src/Mapper.cxx @@ -42,6 +42,8 @@ static constexpr Domain mapper_domain("mapper"); +#ifdef ENABLE_DATABASE + /** * The absolute path of the music directory encoded in UTF-8. */ @@ -54,6 +56,8 @@ static size_t music_dir_utf8_length; */ static AllocatedPath music_dir_fs = AllocatedPath::Null(); +#endif + /** * The absolute path of the playlist directory encoded in the * filesystem character set. @@ -91,6 +95,8 @@ check_directory(const char *path_utf8, const AllocatedPath &path_fs) "No permission to read directory: %s", path_utf8); } +#ifdef ENABLE_DATABASE + static void mapper_set_music_dir(AllocatedPath &&path) { @@ -105,6 +111,8 @@ mapper_set_music_dir(AllocatedPath &&path) check_directory(music_dir_utf8.c_str(), music_dir_fs); } +#endif + static void mapper_set_playlist_dir(AllocatedPath &&path) { @@ -119,8 +127,12 @@ mapper_set_playlist_dir(AllocatedPath &&path) void mapper_init(AllocatedPath &&_music_dir, AllocatedPath &&_playlist_dir) { +#ifdef ENABLE_DATABASE if (!_music_dir.IsNull()) mapper_set_music_dir(std::move(_music_dir)); +#else + (void)_music_dir; +#endif if (!_playlist_dir.IsNull()) mapper_set_playlist_dir(std::move(_playlist_dir)); @@ -130,6 +142,8 @@ void mapper_finish(void) { } +#ifdef ENABLE_DATABASE + const char * mapper_get_music_directory_utf8(void) { @@ -144,17 +158,25 @@ mapper_get_music_directory_fs(void) return music_dir_fs; } +#endif + const char * map_to_relative_path(const char *path_utf8) { +#ifdef ENABLE_DATABASE return !music_dir_utf8.empty() && memcmp(path_utf8, music_dir_utf8.c_str(), music_dir_utf8_length) == 0 && PathTraitsUTF8::IsSeparator(path_utf8[music_dir_utf8_length]) ? path_utf8 + music_dir_utf8_length + 1 : path_utf8; +#else + return path_utf8; +#endif } +#ifdef ENABLE_DATABASE + AllocatedPath map_uri_fs(const char *uri) { @@ -240,15 +262,24 @@ map_song_fs(const Song &song) : map_directory_child_fs(*song.parent, song.uri); } +#endif + AllocatedPath map_song_fs(const DetachedSong &song) { if (song.IsAbsoluteFile()) return AllocatedPath::FromUTF8(song.GetRealURI()); - else + else { +#ifdef ENABLE_DATABASE return map_uri_fs(song.GetURI()); +#else + return AllocatedPath::Null(); +#endif + } } +#ifdef ENABLE_DATABASE + std::string map_fs_to_utf8(const char *path_fs) { @@ -261,6 +292,8 @@ map_fs_to_utf8(const char *path_fs) return PathToUTF8(path_fs); } +#endif + const AllocatedPath & map_spl_path(void) { |