mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-08-19 15:39:46 +00:00
Get the config file path from cmake.
This commit is contained in:
parent
e2cfdb9edb
commit
56735c9d86
5 changed files with 34 additions and 1 deletions
|
@ -23,5 +23,6 @@
|
|||
#define VERSION_MINOR @PROJECT_VERSION_MINOR@
|
||||
#define VERSION_BETA @PROJECT_VERSION_BETA@
|
||||
#define VERSION_PATCH @PROJECT_VERSION_PATCH@
|
||||
#define CONFIG_FILE_PATH "@DINDEXER_CONFIG_FILE@"
|
||||
|
||||
#endif
|
||||
|
|
17
src/main.cpp
17
src/main.cpp
|
@ -26,6 +26,8 @@
|
|||
# include <mutex>
|
||||
# include <condition_variable>
|
||||
#endif
|
||||
#include <wordexp.h>
|
||||
#include "dindexerConfig.h"
|
||||
#include "filesearcher.hpp"
|
||||
#include "indexer.hpp"
|
||||
#include "settings.hpp"
|
||||
|
@ -33,6 +35,7 @@
|
|||
|
||||
namespace {
|
||||
void run_hash_calculation ( din::Indexer& parIndexer, bool parShowProgress );
|
||||
std::string expand ( const char* parString );
|
||||
} //unnamed namespace
|
||||
|
||||
int main (int parArgc, char* parArgv[]) {
|
||||
|
@ -61,7 +64,7 @@ int main (int parArgc, char* parArgv[]) {
|
|||
|
||||
din::DinDBSettings settings;
|
||||
{
|
||||
const bool loaded = din::load_settings("dindexerrc.yml", settings);
|
||||
const bool loaded = din::load_settings(expand(CONFIG_FILE_PATH), settings);
|
||||
if (not loaded) {
|
||||
std::cerr << "Can't load settings from dindexerrc.yml, quitting\n";
|
||||
return 1;
|
||||
|
@ -141,4 +144,16 @@ namespace {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string expand (const char* parString) {
|
||||
wordexp_t p;
|
||||
wordexp(parString, &p, 0);
|
||||
char** w = p.we_wordv;
|
||||
std::ostringstream oss;
|
||||
for (std::size_t z = 0; z < p.we_wordc; ++z) {
|
||||
oss << w[z];
|
||||
}
|
||||
wordfree(&p);
|
||||
return oss.str();
|
||||
}
|
||||
} //unnamed namespace
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue