Added: Regex filtering for pbo index.

Changed: Logging cleanup, default files and paths.
Changed: initialization order of plugin (PRE-Init for vehicle registration).
This commit is contained in:
jaynus 2015-05-10 17:45:38 -07:00
parent d4a354d5b8
commit 91bd1e7c7b
7 changed files with 26 additions and 9 deletions

View File

@ -3,5 +3,4 @@
// Handle damage to local vehicles
[QGVAR(hp), FUNC(dispatchHitPart)] call EFUNC(common,addEventHandler);
[] call FUNC(initializeExtension);
[FUNC(monitorResultsPFH), 0, []] call CBA_fnc_addPerFrameHandler;

View File

@ -30,4 +30,6 @@ FUNC(_textVector) = {
_str
};
[] call FUNC(initializeExtension);
ADDON = true;

View File

@ -784,12 +784,12 @@ namespace el {
#else
# if ELPP_OS_UNIX
# if ELPP_OS_ANDROID
static const char* kDefaultLogFile = "logs/myeasylog.log";
static const char* kDefaultLogFile = "logs/ace.log";
# else
static const char* kDefaultLogFile = "logs/myeasylog.log";
static const char* kDefaultLogFile = "logs/ace.log";
# endif // ELPP_OS_ANDROID
# elif ELPP_OS_WINDOWS
static const char* kDefaultLogFile = "logs\\myeasylog.log";
static const char* kDefaultLogFile = "logs\\ace.log";
# endif // ELPP_OS_UNIX
#endif // defined(ELPP_DEFAULT_LOG_FILE)
#if !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG)

View File

@ -2,6 +2,7 @@
#include <sstream>
#include <iterator>
#include <algorithm>
#include <regex>
#define NT_SUCCESS(x) ((x) >= 0)
#define STATUS_INFO_LENGTH_MISMATCH 0xc0000004
@ -103,7 +104,12 @@ namespace ace {
namespace pbo {
bool search::index_files() {
return index_files(".*");
}
bool search::index_files(const std::string &filter) {
std::ifstream pbo_stream;
std::regex txt_regex(filter);
if (_active_pbo_list.size() < 1)
return false;
@ -118,10 +124,12 @@ namespace ace {
ace::pbo::archive _archive(pbo_stream);
for (ace::pbo::entry_p & entry : _archive.entries) {
if (entry->filename != "") {
std::string full_virtual_path = _archive.info->data + "\\" + entry->filename;
std::transform(full_virtual_path.begin(), full_virtual_path.end(), full_virtual_path.begin(), ::tolower);
_file_pbo_index[full_virtual_path] = pbo_file_path;
//LOG(DEBUG) << full_virtual_path << " = " << pbo_file_path;
if (std::regex_match(entry->filename, txt_regex)) {
std::string full_virtual_path = _archive.info->data + "\\" + entry->filename;
std::transform(full_virtual_path.begin(), full_virtual_path.end(), full_virtual_path.begin(), ::tolower);
_file_pbo_index[full_virtual_path] = pbo_file_path;
//LOG(DEBUG) << full_virtual_path << " = " << pbo_file_path;
}
}
}
pbo_stream.close();
@ -130,6 +138,11 @@ namespace ace {
return true;
}
search::search(const std::string & filter) {
generate_pbo_list();
index_files(filter);
}
search::search() {
generate_pbo_list();
index_files();

View File

@ -8,11 +8,13 @@ namespace ace {
class search {
public:
search();
search(const std::string &);
const std::unordered_map<std::string, std::string> & file_index() { return _file_pbo_index; }
const std::vector<std::string> & active_pbo_list() { return _active_pbo_list; }
protected:
bool index_files();
bool index_files(const std::string &);
bool generate_pbo_list();
std::unordered_map<std::string, std::string> _file_pbo_index;

View File

@ -7,7 +7,7 @@ namespace ace {
bool model_collection::init(void) {
if (_initialized) return true;
_pbo_searcher = std::make_shared<ace::pbo::search>();
_pbo_searcher = std::make_shared<ace::pbo::search>(".*\.p3d");
_initialized = true;
_ready = true;

View File

@ -28,6 +28,7 @@ namespace ace {
bool initialized(void) const { return _initialized; }
bool ready(void) const { return _ready; }
protected:
bool _load_model(const std::string &, const std::string &);