Skip to content

Commit

Permalink
Use const std::string &
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-derevenetz committed Dec 1, 2024
1 parent 1a0e135 commit 40d7049
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/engine/dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace
return ( strCmp( filenamePtr, filter.c_str() ) == 0 );
}

void getFilesFromDirectory( const std::string_view path, const std::string & filter, const bool needExactMatch, ListFiles & files )
void getFilesFromDirectory( const std::string & path, const std::string & filter, const bool needExactMatch, ListFiles & files )
{
std::string correctedPath;
if ( !System::GetCaseInsensitivePath( path, correctedPath ) ) {
Expand Down Expand Up @@ -125,17 +125,17 @@ void ListFiles::Append( ListFiles && files )
}
}

void ListFiles::ReadDir( const std::string_view path, const std::string & filter )
void ListFiles::ReadDir( const std::string & path, const std::string & filter )
{
getFilesFromDirectory( path, filter, false, *this );
}

void ListFiles::FindFileInDir( const std::string_view path, const std::string & fileName )
void ListFiles::FindFileInDir( const std::string & path, const std::string & fileName )
{
getFilesFromDirectory( path, fileName, true, *this );
}

bool ListFiles::IsEmpty( const std::string_view path, const std::string & filter )
bool ListFiles::IsEmpty( const std::string & path, const std::string & filter )
{
ListFiles list;
list.ReadDir( path, filter );
Expand Down
7 changes: 3 additions & 4 deletions src/engine/dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,19 @@

#include <list>
#include <string>
#include <string_view>

struct ListFiles : public std::list<std::string>
{
void Append( ListFiles && files );

// Adds files from the 'path' directory ending in 'filter' to the list, case-insensitive.
void ReadDir( const std::string_view path, const std::string & filter );
void ReadDir( const std::string & path, const std::string & filter );

// Adds files from the 'path' directory with names matching 'fileName' to the list, case-insensitive.
void FindFileInDir( const std::string_view path, const std::string & fileName );
void FindFileInDir( const std::string & path, const std::string & fileName );

// Returns true if there are no files in the 'path' directory with names ending in 'filter', case-insensitive, otherwise returns false.
static bool IsEmpty( const std::string_view path, const std::string & filter );
static bool IsEmpty( const std::string & path, const std::string & filter );
};

#endif

0 comments on commit 40d7049

Please sign in to comment.