summaryrefslogtreecommitdiff
path: root/src/fs/Traits.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-03-07 09:02:02 +0100
committerMax Kellermann <max@musicpd.org>2020-03-07 09:30:56 +0100
commitb7ce4523083d5c98b4d944045a318b6a3e590a46 (patch)
treee8aa7c5edb2ed58f2619f62644f6cf5a4a4b4f45 /src/fs/Traits.hxx
parent5faf76051d3a99c637653c76d0fc762e75b87bd5 (diff)
fs/Traits: add IsSpecialFilename()
Merge some duplicate code in a central library.
Diffstat (limited to 'src/fs/Traits.hxx')
-rw-r--r--src/fs/Traits.hxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx
index 6a7e31f0c..735ec6c9e 100644
--- a/src/fs/Traits.hxx
+++ b/src/fs/Traits.hxx
@@ -109,6 +109,12 @@ struct PathTraitsFS {
}
gcc_pure gcc_nonnull_all
+ static bool IsSpecialFilename(const_pointer_type name) noexcept {
+ return (name[0] == '.' && name[1] == 0) ||
+ (name[0] == '.' && name[1] == '.' && name[2] == 0);
+ }
+
+ gcc_pure gcc_nonnull_all
static size_t GetLength(const_pointer_type p) noexcept {
return StringLength(p);
}
@@ -217,6 +223,12 @@ struct PathTraitsUTF8 {
}
gcc_pure gcc_nonnull_all
+ static bool IsSpecialFilename(const_pointer_type name) noexcept {
+ return (name[0] == '.' && name[1] == 0) ||
+ (name[0] == '.' && name[1] == '.' && name[2] == 0);
+ }
+
+ gcc_pure gcc_nonnull_all
static size_t GetLength(const_pointer_type p) noexcept {
return StringLength(p);
}