janwas
871cdb6ef9
- error codes now accessed as ERR::NO_MEM, INFO::OK etc. - no more X-macros => the above are now recognized by visual assist - error codes are defined by the module originating them (lib_errors has some generic ones) => no full rebuild when adding some - error descriptions are now in C++ files => can be changed without full rebuild added AT_STARTUP in lib.h. This was SVN commit r4374.
47 lines
890 B
C++
47 lines
890 B
C++
#include "precompiled.h"
|
|
|
|
#include "VFSUtil.h"
|
|
#include "lib/res/file/vfs.h"
|
|
|
|
#include "CLogger.h"
|
|
#define LOG_CATEGORY "vfs"
|
|
|
|
#include <deque>
|
|
|
|
using namespace VFSUtil;
|
|
|
|
// Because I'm lazy, and it saves a few lines of code in other places:
|
|
bool VFSUtil::FindFiles (const CStr& dirname, const char* filter, FileList& files)
|
|
{
|
|
files.clear();
|
|
|
|
Handle dir = vfs_dir_open(dirname);
|
|
if (dir <= 0)
|
|
{
|
|
LOG(ERROR, LOG_CATEGORY, "Error opening directory '%s' (%lld)", dirname.c_str(), dir);
|
|
return false;
|
|
}
|
|
|
|
int err;
|
|
DirEnt entry;
|
|
while ((err = vfs_dir_next_ent(dir, &entry, filter)) == 0)
|
|
{
|
|
CStr path = dirname+entry.name;
|
|
if(DIRENT_IS_DIR(&entry))
|
|
path += '/';
|
|
files.push_back(path);
|
|
}
|
|
|
|
if (err != ERR::DIR_END)
|
|
{
|
|
LOG(ERROR, LOG_CATEGORY, "Error reading files from directory '%s' (%d)", dirname.c_str(), err);
|
|
return false;
|
|
}
|
|
|
|
vfs_dir_close(dir);
|
|
|
|
return true;
|
|
|
|
}
|
|
|