fs/Traits: add IsAbsolute(string_view)
This commit is contained in:
parent
66ee03741d
commit
f6cee35896
src
@ -94,7 +94,7 @@ print_storage_uri(Client &client, Response &r, const Storage &storage)
|
||||
if (uri.empty())
|
||||
return;
|
||||
|
||||
if (PathTraitsUTF8::IsAbsolute(uri.c_str())) {
|
||||
if (PathTraitsUTF8::IsAbsolute(uri)) {
|
||||
/* storage points to local directory */
|
||||
|
||||
if (!client.IsLocal())
|
||||
|
@ -337,7 +337,7 @@ public:
|
||||
|
||||
[[gnu::pure]]
|
||||
bool IsAbsolute() const noexcept {
|
||||
return Traits::IsAbsolute(c_str());
|
||||
return Traits::IsAbsolute(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -130,6 +130,15 @@ struct PathTraitsFS {
|
||||
return IsSeparator(*p);
|
||||
}
|
||||
|
||||
[[gnu::pure]]
|
||||
static bool IsAbsolute(string_view p) noexcept {
|
||||
#ifdef _WIN32
|
||||
if (IsDrive(p) && IsSeparator(p[2]))
|
||||
return true;
|
||||
#endif
|
||||
return !p.empty() && IsSeparator(p.front());
|
||||
}
|
||||
|
||||
[[gnu::pure]] [[gnu::nonnull]]
|
||||
static bool IsSpecialFilename(const_pointer name) noexcept {
|
||||
return (name[0] == '.' && name[1] == 0) ||
|
||||
@ -274,6 +283,15 @@ struct PathTraitsUTF8 {
|
||||
return IsSeparator(*p);
|
||||
}
|
||||
|
||||
[[gnu::pure]]
|
||||
static bool IsAbsolute(string_view p) noexcept {
|
||||
#ifdef _WIN32
|
||||
if (IsDrive(p) && IsSeparator(p[2]))
|
||||
return true;
|
||||
#endif
|
||||
return !p.empty() && IsSeparator(p.front());
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this any kind of absolute URI? (Unlike IsAbsolute(),
|
||||
* this includes URIs/URLs with a scheme)
|
||||
|
Loading…
x
Reference in New Issue
Block a user