Skip to content

Commit

Permalink
Removed the functions strisdot() and strisdotdot()
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekazakov committed Dec 19, 2024
1 parent 48329d7 commit 102de54
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
13 changes: 0 additions & 13 deletions Source/Utility/include/Utility/PathManip.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 3 additions & 3 deletions Source/VFS/source/Native/Fetching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Source/VFS/source/Native/Host.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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]) )
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions Source/VFS/source/NetSFTP/SFTPHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 102de54

Please sign in to comment.