mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-19 22:51:30 +02:00
Implement search for DirectoryList
This commit is contained in:
@@ -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> Client::DirectorySearch(std::string directory, std::string search, std::vector<std::string> extensions)
|
||||||
{
|
{
|
||||||
std::vector<std::string> results;
|
|
||||||
|
|
||||||
//Get full file listing
|
//Get full file listing
|
||||||
std::vector<std::string> directoryList;
|
std::vector<std::string> directoryList;
|
||||||
#if defined(WIN32) && !defined(__GNUC__)
|
#if defined(WIN32) && !defined(__GNUC__)
|
||||||
@@ -173,9 +171,29 @@ std::vector<std::string> Client::DirectorySearch(std::string directory, std::str
|
|||||||
closedir(directoryHandle);
|
closedir(directoryHandle);
|
||||||
#endif
|
#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
|
//Filter results
|
||||||
return directoryList;
|
return searchResults;
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<unsigned char> Client::ReadFile(std::string filename)
|
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),
|
actionCallback(NULL),
|
||||||
masked(false),
|
masked(false),
|
||||||
border(true),
|
border(true),
|
||||||
mouseDown(false)
|
mouseDown(false),
|
||||||
|
limit(0)
|
||||||
{
|
{
|
||||||
placeHolder = textboxPlaceholder;
|
placeHolder = textboxPlaceholder;
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@ class Textbox : public Label
|
|||||||
{
|
{
|
||||||
friend class TextboxAction;
|
friend class TextboxAction;
|
||||||
protected:
|
protected:
|
||||||
|
size_t limit;
|
||||||
bool mouseDown;
|
bool mouseDown;
|
||||||
bool masked, border;
|
bool masked, border;
|
||||||
int cursor, cursorPositionX, cursorPositionY;
|
int cursor, cursorPositionX, cursorPositionY;
|
||||||
|
Reference in New Issue
Block a user