diff --git a/Source/Utility/include/Utility/PathManip.h b/Source/Utility/include/Utility/PathManip.h index 25cd99a2b..69b0c2712 100644 --- a/Source/Utility/include/Utility/PathManip.h +++ b/Source/Utility/include/Utility/PathManip.h @@ -54,19 +54,6 @@ bool GetExtensionFromPath(const char *_path, char *_buf); */ bool GetExtensionFromRelPath(const char *_path, char *_buf); -inline bool strisdot(const char *s) noexcept -{ - return s && s[0] == '.' && s[1] == 0; -} -inline bool strisdotdot(const char *s) noexcept -{ - return s && s[0] == '.' && s[1] == '.' && s[2] == 0; -} -inline bool strisdotdot(const std::string &s) noexcept -{ - return strisdotdot(s.c_str()); -} - // prefer PathManip::EnsureTrailingSlash() instead, semantically equal inline std::string EnsureTrailingSlash(std::string _s) { diff --git a/Source/VFS/source/Native/Fetching.cpp b/Source/VFS/source/Native/Fetching.cpp index b573ae638..082f18a0d 100644 --- a/Source/VFS/source/Native/Fetching.cpp +++ b/Source/VFS/source/Native/Fetching.cpp @@ -216,9 +216,9 @@ int Fetching::ReadDirAttributesStat(const int _dir_fd, static const auto dirents_reserve_amount = 64; dirents.reserve(dirents_reserve_amount); while( auto entp = ::_readdir_unlocked(dirp, 1) ) { - if( entp->d_ino == 0 || // apple's documentation suggest to skip such files - strisdot(entp->d_name) || // do not process self entry - strisdotdot(entp->d_name) ) // do not process parent entry + if( entp->d_ino == 0 || // apple's documentation suggest to skip such files + entp->d_name == std::string_view{"."} || // do not process self entry + entp->d_name == std::string_view{".."} ) // do not process parent entry continue; dirents.emplace_back(std::string(entp->d_name, entp->d_namlen), entp->d_ino, entp->d_type); diff --git a/Source/VFS/source/Native/Host.mm b/Source/VFS/source/Native/Host.mm index 876f36870..1ea4198db 100644 --- a/Source/VFS/source/Native/Host.mm +++ b/Source/VFS/source/Native/Host.mm @@ -152,7 +152,7 @@ if( _flags & VFSFlags::F_LoadDisplayNames ) if( S_ISDIR(listing_source.unix_modes[_n]) && !listing_source.filenames[_n].empty() && - !strisdotdot(listing_source.filenames[_n]) ) { + listing_source.filenames[_n] != ".." ) { static auto &dnc = DisplayNamesCache::Instance(); if( auto display_name = dnc.DisplayName( _params.inode, _params.dev, listing_source.directories[0] + listing_source.filenames[_n]) ) @@ -310,7 +310,7 @@ if( _flags & VFSFlags::F_LoadDisplayNames ) if( S_ISDIR(listing_source.unix_modes[0]) && !listing_source.filenames[0].empty() && - !strisdotdot(listing_source.filenames[0]) ) { + listing_source.filenames[0] != ".." ) { static auto &dnc = DisplayNamesCache::Instance(); if( auto display_name = dnc.DisplayName(_params.inode, _params.dev, path) ) listing_source.display_filenames.insert(0, display_name); diff --git a/Source/VFS/source/NetSFTP/SFTPHost.cpp b/Source/VFS/source/NetSFTP/SFTPHost.cpp index 1d258915b..56575391b 100644 --- a/Source/VFS/source/NetSFTP/SFTPHost.cpp +++ b/Source/VFS/source/NetSFTP/SFTPHost.cpp @@ -423,9 +423,9 @@ int SFTPHost::FetchDirectoryListing(std::string_view _path, LIBSSH2_SFTP_ATTRIBUTES attrs; while( libssh2_sftp_readdir_ex(sftp_handle, filename, sizeof(filename), nullptr, 0, &attrs) > 0 ) { int index = 0; - if( strisdot(filename) ) - continue; // do not process self entry - else if( strisdotdot(filename) ) { // special case for dot-dot directory + if( filename == std::string_view{"."} ) + continue; // do not process self entry + else if( filename == std::string_view{".."} ) { // special case for dot-dot directory if( !should_have_dot_dot ) continue; // skip .. for root directory or if there's an option to exclude // dot-dot entries