From e907ff43aec3690858d0a9174ff79e884edd7b89 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 16 Sep 2020 20:57:37 +0200 Subject: [PATCH] command/file, storage/{nfs,smbclient}: use PathTraitsFS::IsSpecialFilename() Eliminate some duplicate code. --- src/command/FileCommands.cxx | 4 +--- src/storage/plugins/NfsStorage.cxx | 4 +--- src/storage/plugins/SmbclientStorage.cxx | 6 ++---- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/command/FileCommands.cxx b/src/command/FileCommands.cxx index 448da2caf..29685713d 100644 --- a/src/command/FileCommands.cxx +++ b/src/command/FileCommands.cxx @@ -50,9 +50,7 @@ gcc_pure static bool SkipNameFS(PathTraitsFS::const_pointer_type name_fs) noexcept { - return name_fs[0] == '.' && - (name_fs[1] == 0 || - (name_fs[1] == '.' && name_fs[2] == 0)); + return PathTraitsFS::IsSpecialFilename(name_fs); } gcc_pure diff --git a/src/storage/plugins/NfsStorage.cxx b/src/storage/plugins/NfsStorage.cxx index e485fd8e4..e7d125a81 100644 --- a/src/storage/plugins/NfsStorage.cxx +++ b/src/storage/plugins/NfsStorage.cxx @@ -307,9 +307,7 @@ gcc_pure static bool SkipNameFS(PathTraitsFS::const_pointer_type name) noexcept { - return name[0] == '.' && - (name[1] == 0 || - (name[1] == '.' && name[2] == 0)); + return PathTraitsFS::IsSpecialFilename(name); } static void diff --git a/src/storage/plugins/SmbclientStorage.cxx b/src/storage/plugins/SmbclientStorage.cxx index 0324bf219..ff6262f58 100644 --- a/src/storage/plugins/SmbclientStorage.cxx +++ b/src/storage/plugins/SmbclientStorage.cxx @@ -144,11 +144,9 @@ SmbclientStorage::OpenDirectory(const char *uri_utf8) gcc_pure static bool -SkipNameFS(const char *name) noexcept +SkipNameFS(PathTraitsFS::const_pointer_type name) noexcept { - return name[0] == '.' && - (name[1] == 0 || - (name[1] == '.' && name[2] == 0)); + return PathTraitsFS::IsSpecialFilename(name); } SmbclientDirectoryReader::~SmbclientDirectoryReader()