summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Main.cxx2
-rw-r--r--src/Mapper.cxx46
-rw-r--r--src/Mapper.hxx2
3 files changed, 19 insertions, 31 deletions
diff --git a/src/Main.cxx b/src/Main.cxx
index 7a2789b0c..b0cc74f44 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -161,7 +161,7 @@ glue_mapper_init(Error &error)
}
#endif
- mapper_init(std::move(music_dir), std::move(playlist_dir));
+ mapper_init(std::move(playlist_dir));
return true;
}
diff --git a/src/Mapper.cxx b/src/Mapper.cxx
index f97cc3f9c..7baad9459 100644
--- a/src/Mapper.cxx
+++ b/src/Mapper.cxx
@@ -28,36 +28,20 @@
#include "fs/Charset.hxx"
#include "fs/CheckFile.hxx"
-#include <assert.h>
-
#ifdef ENABLE_DATABASE
-
-/**
- * The absolute path of the music directory encoded in the filesystem
- * character set.
- */
-static AllocatedPath music_dir_fs = AllocatedPath::Null();
-
+#include "storage/StorageInterface.hxx"
+#include "Instance.hxx"
+#include "Main.hxx"
#endif
+#include <assert.h>
+
/**
* The absolute path of the playlist directory encoded in the
* filesystem character set.
*/
static AllocatedPath playlist_dir_fs = AllocatedPath::Null();
-#ifdef ENABLE_DATABASE
-
-static void
-mapper_set_music_dir(AllocatedPath &&path)
-{
- assert(!path.IsNull());
-
- music_dir_fs = std::move(path);
-}
-
-#endif
-
static void
mapper_set_playlist_dir(AllocatedPath &&path)
{
@@ -69,15 +53,8 @@ mapper_set_playlist_dir(AllocatedPath &&path)
}
void
-mapper_init(AllocatedPath &&_music_dir, AllocatedPath &&_playlist_dir)
+mapper_init(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));
}
@@ -94,6 +71,10 @@ map_uri_fs(const char *uri)
assert(uri != nullptr);
assert(*uri != '/');
+ if (instance->storage == nullptr)
+ return AllocatedPath::Null();
+
+ const auto music_dir_fs = instance->storage->MapFS("");
if (music_dir_fs.IsNull())
return AllocatedPath::Null();
@@ -108,6 +89,13 @@ std::string
map_fs_to_utf8(const char *path_fs)
{
if (PathTraitsFS::IsSeparator(path_fs[0])) {
+ if (instance->storage == nullptr)
+ return std::string();
+
+ const auto music_dir_fs = instance->storage->MapFS("");
+ if (music_dir_fs.IsNull())
+ return std::string();
+
path_fs = music_dir_fs.RelativeFS(path_fs);
if (path_fs == nullptr || *path_fs == 0)
return std::string();
diff --git a/src/Mapper.hxx b/src/Mapper.hxx
index a535c5eec..7ff41f239 100644
--- a/src/Mapper.hxx
+++ b/src/Mapper.hxx
@@ -33,7 +33,7 @@
class AllocatedPath;
void
-mapper_init(AllocatedPath &&music_dir, AllocatedPath &&playlist_dir);
+mapper_init(AllocatedPath &&playlist_dir);
void mapper_finish(void);