CPath can now return the file list with a path filter.
This commit is contained in:
parent
28807c5eea
commit
c736145c2f
3 changed files with 71 additions and 1 deletions
|
@ -200,6 +200,10 @@ public:
|
|||
*/
|
||||
void getFileListByName(const std::string &extension, const std::string &name, std::vector<std::string> &filenames);
|
||||
|
||||
/** Create a list of file having the requested string in the path and the requested extension.
|
||||
*/
|
||||
void getFileListByPath(const std::string &extension, const std::string &path, std::vector<std::string> &filenames);
|
||||
|
||||
/** Make a path relative to another if possible, else doesn't change it.
|
||||
* \param basePath is the base path to be relative to.
|
||||
* \param relativePath is the path to make relative to basePath.
|
||||
|
@ -492,6 +496,10 @@ public:
|
|||
*/
|
||||
static void getFileListByName(const std::string &extension, const std::string &name, std::vector<std::string> &filenames);
|
||||
|
||||
/** Create a list of file having the requested string in the path and the requested extension
|
||||
*/
|
||||
static void getFileListByPath(const std::string &extension, const std::string &path, std::vector<std::string> &filenames);
|
||||
|
||||
/** Make a path relative to another if possible, else doesn't change it.
|
||||
* \param basePath is the base path to be relative to.
|
||||
* \param relativePath is the path to make relative to basePath.
|
||||
|
|
|
@ -219,6 +219,67 @@ void CFileContainer::getFileListByName(const std::string &extension, const std::
|
|||
}
|
||||
}
|
||||
|
||||
void CPath::getFileListByPath(const std::string &extension, const std::string &path, std::vector<std::string> &filenames)
|
||||
{
|
||||
getInstance()->_FileContainer.getFileListByPath(extension, path, filenames);
|
||||
}
|
||||
|
||||
void CFileContainer::getFileListByPath(const std::string &extension, const std::string &path, std::vector<std::string> &filenames)
|
||||
{
|
||||
if (!_MemoryCompressed)
|
||||
{
|
||||
TFiles::iterator first(_Files.begin()), last(_Files.end());
|
||||
|
||||
if( !path.empty() )
|
||||
{
|
||||
for (; first != last; ++ first)
|
||||
{
|
||||
string ext = SSMext.get(first->second.idExt);
|
||||
string p = SSMpath.get(first->second.idPath);
|
||||
if (p.find(path) != string::npos && (ext == extension || extension.empty()))
|
||||
{
|
||||
filenames.push_back(first->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if extension is empty we keep all files
|
||||
else
|
||||
{
|
||||
for (; first != last; ++ first)
|
||||
{
|
||||
filenames.push_back(first->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// compressed memory version
|
||||
std::vector<CFileContainer::CMCFileEntry>::iterator first(_MCFiles.begin()), last(_MCFiles.end());
|
||||
|
||||
if( !path.empty() )
|
||||
{
|
||||
for (; first != last; ++ first)
|
||||
{
|
||||
string ext = SSMext.get(first->idExt);
|
||||
string p = SSMpath.get(first->idPath);
|
||||
|
||||
if (strstr(p.c_str(), path.c_str()) != NULL && (ext == extension || extension.empty()))
|
||||
{
|
||||
filenames.push_back(first->Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if extension is empty we keep all files
|
||||
else
|
||||
{
|
||||
for (; first != last; ++ first)
|
||||
{
|
||||
filenames.push_back(first->Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPath::clearMap ()
|
||||
{
|
||||
getInstance()->_FileContainer.clearMap();
|
||||
|
|
|
@ -24,7 +24,8 @@ void TextureChooser::load()
|
|||
listWidget->clear();
|
||||
|
||||
std::vector< std::string > textures;
|
||||
NLMISC::CPath::getFileList( "tga", textures );
|
||||
//NLMISC::CPath::getFileList( "tga", textures );
|
||||
NLMISC::CPath::getFileListByPath( "tga", "interfaces", textures );
|
||||
|
||||
std::vector< std::string >::const_iterator itr = textures.begin();
|
||||
while( itr != textures.end() )
|
||||
|
|
Loading…
Reference in a new issue