fs/Traits: add PathTraitsUTF8::IsAbsoluteOrHasScheme()
This commit is contained in:
parent
ef2fc4e6f6
commit
1761fb14af
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "Traits.hxx"
|
#include "Traits.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
|
#include "util/UriExtract.hxx"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -220,6 +221,12 @@ PathTraitsUTF8::Build(string_view a, string_view b) noexcept
|
|||||||
return BuildPathImpl<PathTraitsUTF8>(a, b);
|
return BuildPathImpl<PathTraitsUTF8>(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PathTraitsUTF8::IsAbsoluteOrHasScheme(const_pointer p) noexcept
|
||||||
|
{
|
||||||
|
return IsAbsolute(p) || uri_has_scheme(p);
|
||||||
|
}
|
||||||
|
|
||||||
PathTraitsUTF8::const_pointer
|
PathTraitsUTF8::const_pointer
|
||||||
PathTraitsUTF8::GetBase(const_pointer p) noexcept
|
PathTraitsUTF8::GetBase(const_pointer p) noexcept
|
||||||
{
|
{
|
||||||
|
@ -274,6 +274,13 @@ struct PathTraitsUTF8 {
|
|||||||
return IsSeparator(*p);
|
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
|
gcc_pure gcc_nonnull_all
|
||||||
static bool IsSpecialFilename(const_pointer name) noexcept {
|
static bool IsSpecialFilename(const_pointer name) noexcept {
|
||||||
return (name[0] == '.' && name[1] == 0) ||
|
return (name[0] == '.' && name[1] == 0) ||
|
||||||
|
@ -92,8 +92,8 @@ playlist_check_translate_song(DetachedSong &song, std::string_view base_uri,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (base_uri.data() != nullptr && !uri_has_scheme(uri) &&
|
if (base_uri.data() != nullptr &&
|
||||||
!PathTraitsUTF8::IsAbsolute(uri))
|
!PathTraitsUTF8::IsAbsoluteOrHasScheme(uri))
|
||||||
song.SetURI(PathTraitsUTF8::Build(base_uri, uri));
|
song.SetURI(PathTraitsUTF8::Build(base_uri, uri));
|
||||||
|
|
||||||
return playlist_check_load_song(song, loader);
|
return playlist_check_load_song(song, loader);
|
||||||
|
@ -60,7 +60,7 @@ DetachedSong::IsInDatabase() const noexcept
|
|||||||
GetRealURI() is never relative */
|
GetRealURI() is never relative */
|
||||||
|
|
||||||
const char *_uri = GetURI();
|
const char *_uri = GetURI();
|
||||||
return !uri_has_scheme(_uri) && !PathTraitsUTF8::IsAbsolute(_uri);
|
return !PathTraitsUTF8::IsAbsoluteOrHasScheme(_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
SignedSongTime
|
SignedSongTime
|
||||||
|
Loading…
Reference in New Issue
Block a user