Implement search for DirectoryList
This commit is contained in:
parent
c14a008d46
commit
df3b1e2a62
@ -132,8 +132,6 @@ std::vector<std::string> Client::DirectorySearch(std::string directory, std::str
|
||||
|
||||
std::vector<std::string> Client::DirectorySearch(std::string directory, std::string search, std::vector<std::string> extensions)
|
||||
{
|
||||
std::vector<std::string> results;
|
||||
|
||||
//Get full file listing
|
||||
std::vector<std::string> directoryList;
|
||||
#if defined(WIN32) && !defined(__GNUC__)
|
||||
@ -173,9 +171,29 @@ std::vector<std::string> Client::DirectorySearch(std::string directory, std::str
|
||||
closedir(directoryHandle);
|
||||
#endif
|
||||
|
||||
std::vector<std::string> searchResults;
|
||||
for(std::vector<std::string>::iterator iter = directoryList.begin(), end = directoryList.end(); iter != end; ++iter)
|
||||
{
|
||||
std::string filename = *iter;
|
||||
bool extensionMatch = !extensions.size();
|
||||
for(std::vector<std::string>::iterator extIter = extensions.begin(), extEnd = extensions.end(); extIter != extEnd; ++extIter)
|
||||
{
|
||||
if(filename.find(*extIter)==filename.length()-(*extIter).length())
|
||||
{
|
||||
extensionMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool searchMatch = !search.size();
|
||||
if(search.size() && filename.find(search)!=std::string::npos)
|
||||
searchMatch = true;
|
||||
|
||||
if(searchMatch && extensionMatch)
|
||||
searchResults.push_back(filename);
|
||||
}
|
||||
|
||||
//Filter results
|
||||
return directoryList;
|
||||
return results;
|
||||
return searchResults;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> Client::ReadFile(std::string filename)
|
||||
|
@ -14,7 +14,8 @@ Textbox::Textbox(Point position, Point size, std::string textboxText, std::strin
|
||||
actionCallback(NULL),
|
||||
masked(false),
|
||||
border(true),
|
||||
mouseDown(false)
|
||||
mouseDown(false),
|
||||
limit(0)
|
||||
{
|
||||
placeHolder = textboxPlaceholder;
|
||||
|
||||
|
@ -20,6 +20,7 @@ class Textbox : public Label
|
||||
{
|
||||
friend class TextboxAction;
|
||||
protected:
|
||||
size_t limit;
|
||||
bool mouseDown;
|
||||
bool masked, border;
|
||||
int cursor, cursorPositionX, cursorPositionY;
|
||||
|
Loading…
Reference in New Issue
Block a user