Introduce g_resources.getDirectoryFiles

This can recursively find files in a directory that's not in physfs search
path, this is needed for mapeditor needs, esp the file browser.

We do not want to limit users to the application run directory
so we have to use this.

This function uses boost filesystem.
Prototype:
	g_resources.getDirectoryFiles(directory STRING, filenameOnly BOOL,
	recursive BOOL)

filenameOnly is there if we want to just get the filenames in the
directory.
recursive if we want to loop directories in the directory.
This commit is contained in:
Ahmed Samy
2013-12-25 21:29:38 +02:00
parent 27db78567b
commit 6745bff132
4 changed files with 41 additions and 1 deletions

View File

@@ -25,6 +25,10 @@
#include "declarations.h"
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
// @bindsingleton g_resources
class ResourceManager
{
@@ -61,6 +65,7 @@ public:
bool makeDir(const std::string directory);
std::list<std::string> listDirectoryFiles(const std::string& directoryPath = "");
std::vector<std::string> getDirectoryFiles(const std::string& path, bool filenameOnly, bool recursive);
std::string resolvePath(const std::string& path);
std::string getRealDir(const std::string& path);
@@ -75,6 +80,9 @@ public:
bool isFileType(const std::string& filename, const std::string& type);
ticks_t getFileTime(const std::string& filename);
protected:
std::vector<std::string> discoverPath(const fs::path& path, bool filenameOnly, bool recursive);
private:
std::string m_workDir;
std::string m_writeDir;