Commit 1761fb14 authored by Max Kellermann's avatar Max Kellermann

fs/Traits: add PathTraitsUTF8::IsAbsoluteOrHasScheme()

parent ef2fc4e6
......@@ -19,6 +19,7 @@
#include "Traits.hxx"
#include "util/StringCompare.hxx"
#include "util/UriExtract.hxx"
#include <string.h>
......@@ -220,6 +221,12 @@ PathTraitsUTF8::Build(string_view a, string_view b) noexcept
return BuildPathImpl<PathTraitsUTF8>(a, b);
}
bool
PathTraitsUTF8::IsAbsoluteOrHasScheme(const_pointer p) noexcept
{
return IsAbsolute(p) || uri_has_scheme(p);
}
PathTraitsUTF8::const_pointer
PathTraitsUTF8::GetBase(const_pointer p) noexcept
{
......
......@@ -274,6 +274,13 @@ struct PathTraitsUTF8 {
return IsSeparator(*p);
}
/**
* Is this any kind of absolute URI? (Unlike IsAbsolute(),
* this includes URIs/URLs with a scheme)
*/
[[gnu::pure]] [[gnu::nonnull]]
static bool IsAbsoluteOrHasScheme(const_pointer p) noexcept;
gcc_pure gcc_nonnull_all
static bool IsSpecialFilename(const_pointer name) noexcept {
return (name[0] == '.' && name[1] == 0) ||
......
......@@ -92,8 +92,8 @@ playlist_check_translate_song(DetachedSong &song, std::string_view base_uri,
}
#endif
if (base_uri.data() != nullptr && !uri_has_scheme(uri) &&
!PathTraitsUTF8::IsAbsolute(uri))
if (base_uri.data() != nullptr &&
!PathTraitsUTF8::IsAbsoluteOrHasScheme(uri))
song.SetURI(PathTraitsUTF8::Build(base_uri, uri));
return playlist_check_load_song(song, loader);
......
......@@ -60,7 +60,7 @@ DetachedSong::IsInDatabase() const noexcept
GetRealURI() is never relative */
const char *_uri = GetURI();
return !uri_has_scheme(_uri) && !PathTraitsUTF8::IsAbsolute(_uri);
return !PathTraitsUTF8::IsAbsoluteOrHasScheme(_uri);
}
SignedSongTime
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment