diff options
-rw-r--r-- | src/ConfigPath.cxx | 2 | ||||
-rw-r--r-- | src/DecoderThread.cxx | 2 | ||||
-rw-r--r-- | src/PlaylistFile.cxx | 2 | ||||
-rw-r--r-- | src/PlaylistSave.cxx | 2 | ||||
-rw-r--r-- | src/PlaylistSong.cxx | 4 | ||||
-rw-r--r-- | src/QueueSave.cxx | 3 | ||||
-rw-r--r-- | src/SongUpdate.cxx | 2 | ||||
-rw-r--r-- | src/UpdateWalk.cxx | 2 | ||||
-rw-r--r-- | src/fs/Path.hxx | 31 | ||||
-rw-r--r-- | src/input/ArchiveInputPlugin.cxx | 3 | ||||
-rw-r--r-- | src/input/FileInputPlugin.cxx | 3 | ||||
-rw-r--r-- | src/playlist/EmbeddedCuePlaylistPlugin.cxx | 3 |
12 files changed, 47 insertions, 12 deletions
diff --git a/src/ConfigPath.cxx b/src/ConfigPath.cxx index 7096bcc82..879a1ea56 100644 --- a/src/ConfigPath.cxx +++ b/src/ConfigPath.cxx @@ -118,7 +118,7 @@ ParsePath(const char *path, Error &error) return Path::Null(); return Path::Build(home, path2); - } else if (!g_path_is_absolute(path)) { + } else if (!Path::IsAbsoluteUTF8(path)) { error.Format(path_domain, "not an absolute path: %s", path); return Path::Null(); diff --git a/src/DecoderThread.cxx b/src/DecoderThread.cxx index 1aa60ce3f..aacbb1fb7 100644 --- a/src/DecoderThread.cxx +++ b/src/DecoderThread.cxx @@ -153,7 +153,7 @@ decoder_file_decode(const struct decoder_plugin *plugin, assert(decoder->stream_tag == NULL); assert(decoder->decoder_tag == NULL); assert(path != NULL); - assert(g_path_is_absolute(path)); + assert(Path::IsAbsoluteFS(path)); assert(decoder->dc->state == DecoderState::START); FormatDebug(decoder_thread_domain, "probing plugin %s", plugin->name); diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx index 6085020e0..16c1bcdec 100644 --- a/src/PlaylistFile.cxx +++ b/src/PlaylistFile.cxx @@ -246,7 +246,7 @@ LoadPlaylistFile(const char *utf8path, Error &error) if (!uri_has_scheme(s)) { uri_utf8 = map_fs_to_utf8(s); if (uri_utf8.empty()) { - if (g_path_is_absolute(s)) { + if (Path::IsAbsoluteFS(s)) { uri_utf8 = Path::ToUTF8(s); if (uri_utf8.empty()) continue; diff --git a/src/PlaylistSave.cxx b/src/PlaylistSave.cxx index 6e17b6fc3..7889f778a 100644 --- a/src/PlaylistSave.cxx +++ b/src/PlaylistSave.cxx @@ -56,7 +56,7 @@ void playlist_print_uri(FILE *file, const char *uri) { Path path = playlist_saveAbsolutePaths && !uri_has_scheme(uri) && - !g_path_is_absolute(uri) + !Path::IsAbsoluteUTF8(uri) ? map_uri_fs(uri) : Path::FromUTF8(uri); diff --git a/src/PlaylistSong.cxx b/src/PlaylistSong.cxx index 00735ac60..db6c39b3b 100644 --- a/src/PlaylistSong.cxx +++ b/src/PlaylistSong.cxx @@ -98,7 +98,7 @@ playlist_check_load_song(const Song *song, const char *uri, bool secure) if (uri_has_scheme(uri)) { dest = Song::NewRemote(uri); - } else if (g_path_is_absolute(uri) && secure) { + } else if (Path::IsAbsoluteUTF8(uri) && secure) { dest = Song::LoadFile(uri, nullptr); if (dest == nullptr) return nullptr; @@ -147,7 +147,7 @@ playlist_check_translate_song(Song *song, const char *base_uri, functions */ base_uri = nullptr; - if (g_path_is_absolute(uri)) { + if (Path::IsAbsoluteUTF8(uri)) { /* XXX fs_charset vs utf8? */ const char *suffix = map_to_relative_path(uri); assert(suffix != nullptr); diff --git a/src/QueueSave.cxx b/src/QueueSave.cxx index 8f22e312f..0c036d963 100644 --- a/src/QueueSave.cxx +++ b/src/QueueSave.cxx @@ -28,6 +28,7 @@ #include "TextFile.hxx" #include "util/UriUtil.hxx" #include "util/Error.hxx" +#include "fs/Path.hxx" #include "Log.hxx" #include <glib.h> @@ -92,7 +93,7 @@ queue_load_song(TextFile &file, const char *line, queue *queue) if (g_str_has_prefix(line, SONG_BEGIN)) { const char *uri = line + sizeof(SONG_BEGIN) - 1; - if (!uri_has_scheme(uri) && !g_path_is_absolute(uri)) + if (!uri_has_scheme(uri) && !Path::IsAbsoluteUTF8(uri)) return; Error error; diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index 4c5f35c78..98a58c53e 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -47,7 +47,7 @@ Song::LoadFile(const char *path_utf8, Directory *parent) Song *song; bool ret; - assert((parent == NULL) == g_path_is_absolute(path_utf8)); + assert((parent == NULL) == Path::IsAbsoluteUTF8(path_utf8)); assert(!uri_has_scheme(path_utf8)); assert(strchr(path_utf8, '\n') == NULL); diff --git a/src/UpdateWalk.cxx b/src/UpdateWalk.cxx index d7dfd3015..2bc1f335e 100644 --- a/src/UpdateWalk.cxx +++ b/src/UpdateWalk.cxx @@ -295,7 +295,7 @@ skip_symlink(const Directory *directory, const char *utf8_name) const char *target_str = target.c_str(); - if (g_path_is_absolute(target_str)) { + if (Path::IsAbsoluteFS(target_str)) { /* if the symlink points to an absolute path, see if that path is inside the music directory */ const char *relative = map_to_relative_path(target_str); diff --git a/src/fs/Path.hxx b/src/fs/Path.hxx index bd3f3a94e..a5215c2d6 100644 --- a/src/fs/Path.hxx +++ b/src/fs/Path.hxx @@ -23,6 +23,10 @@ #include "check.h" #include "gcc.h" +#ifdef WIN32 +#include <glib.h> +#endif + #include <algorithm> #include <string> @@ -261,6 +265,33 @@ public: #endif ch == SEPARATOR_UTF8; } + + gcc_pure + static bool IsAbsoluteFS(const_pointer p) { + assert(p != nullptr); + +#ifdef WIN32 + return g_path_is_absolute(p); +#else + return IsSeparatorFS(*p); +#endif + } + + gcc_pure + static bool IsAbsoluteUTF8(const char *p) { + assert(p != nullptr); + +#ifdef WIN32 + return g_path_is_absolute(p); +#else + return IsSeparatorUTF8(*p); +#endif + } + + gcc_pure + bool IsAbsolute() { + return IsAbsoluteFS(c_str()); + } }; #endif diff --git a/src/input/ArchiveInputPlugin.cxx b/src/input/ArchiveInputPlugin.cxx index 08e1cabfe..bc97ad314 100644 --- a/src/input/ArchiveInputPlugin.cxx +++ b/src/input/ArchiveInputPlugin.cxx @@ -26,6 +26,7 @@ #include "InputPlugin.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" +#include "fs/Path.hxx" #include "Log.hxx" #include <glib.h> @@ -49,7 +50,7 @@ input_archive_open(const char *pathname, char *archive, *filename, *suffix, *pname; struct input_stream *is; - if (!g_path_is_absolute(pathname)) + if (!Path::IsAbsoluteFS(pathname)) return NULL; pname = g_strdup(pathname); diff --git a/src/input/FileInputPlugin.cxx b/src/input/FileInputPlugin.cxx index 75103f711..a8557fc4d 100644 --- a/src/input/FileInputPlugin.cxx +++ b/src/input/FileInputPlugin.cxx @@ -24,6 +24,7 @@ #include "InputPlugin.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" +#include "fs/Path.hxx" #include "system/fd_util.h" #include "open.h" @@ -62,7 +63,7 @@ input_file_open(const char *filename, int fd, ret; struct stat st; - if (!g_path_is_absolute(filename)) + if (!Path::IsAbsoluteFS(filename)) return nullptr; fd = open_cloexec(filename, O_RDONLY|O_BINARY, 0); diff --git a/src/playlist/EmbeddedCuePlaylistPlugin.cxx b/src/playlist/EmbeddedCuePlaylistPlugin.cxx index 5fc1f28e0..2a06d2236 100644 --- a/src/playlist/EmbeddedCuePlaylistPlugin.cxx +++ b/src/playlist/EmbeddedCuePlaylistPlugin.cxx @@ -34,6 +34,7 @@ #include "Song.hxx" #include "TagFile.hxx" #include "cue/CueParser.hxx" +#include "fs/Path.hxx" #include <glib.h> #include <assert.h> @@ -95,7 +96,7 @@ embcue_playlist_open_uri(const char *uri, gcc_unused Mutex &mutex, gcc_unused Cond &cond) { - if (!g_path_is_absolute(uri)) + if (!Path::IsAbsoluteUTF8(uri)) /* only local files supported */ return NULL; |