2018-06-09 15:14:08 +00:00
|
|
|
// Copyright 2018, University of Freiburg,
|
|
|
|
// Chair of Algorithms and Data Structures.
|
|
|
|
// Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de>
|
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
#include <limits.h>
|
|
|
|
#include <pwd.h>
|
2018-06-09 15:14:08 +00:00
|
|
|
#include <signal.h>
|
|
|
|
#include <stdio.h>
|
2019-01-10 15:52:59 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
2018-06-09 15:14:08 +00:00
|
|
|
#include <fstream>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include "ad/cppgtfs/Parser.h"
|
|
|
|
#include "ad/cppgtfs/Writer.h"
|
|
|
|
#include "pfaedle/config/ConfigReader.h"
|
|
|
|
#include "pfaedle/config/MotConfig.h"
|
|
|
|
#include "pfaedle/config/MotConfigReader.h"
|
|
|
|
#include "pfaedle/eval/Collector.h"
|
2019-01-10 15:52:59 +00:00
|
|
|
#include "pfaedle/gtfs/Feed.h"
|
|
|
|
#include "pfaedle/gtfs/Writer.h"
|
2018-06-09 15:14:08 +00:00
|
|
|
#include "pfaedle/netgraph/Graph.h"
|
|
|
|
#include "pfaedle/osm/OsmIdSet.h"
|
|
|
|
#include "pfaedle/router/ShapeBuilder.h"
|
|
|
|
#include "pfaedle/trgraph/Graph.h"
|
2019-02-03 11:48:48 +00:00
|
|
|
#include "pfaedle/trgraph/StatGroup.h"
|
2018-06-09 15:14:08 +00:00
|
|
|
#include "util/geo/output/GeoGraphJsonOutput.h"
|
|
|
|
#include "util/geo/output/GeoJsonOutput.h"
|
2018-08-01 12:25:54 +00:00
|
|
|
#include "util/json/Writer.h"
|
2018-06-09 15:14:08 +00:00
|
|
|
#include "util/log/Log.h"
|
2019-05-13 22:11:15 +00:00
|
|
|
#include "util/Misc.h"
|
|
|
|
|
2019-06-28 13:10:15 +00:00
|
|
|
#ifndef CFG_HOME_SUFFIX
|
|
|
|
#define CFG_HOME_SUFFIX "/.config"
|
2019-05-13 22:11:15 +00:00
|
|
|
#endif
|
2019-06-28 13:10:15 +00:00
|
|
|
#ifndef CFG_DIR
|
|
|
|
#define CFG_DIR "/etc"
|
2019-05-13 22:11:15 +00:00
|
|
|
#endif
|
|
|
|
#ifndef CFG_FILE_NAME
|
|
|
|
#define CFG_FILE_NAME "pfaedle.cfg"
|
|
|
|
#endif
|
2018-06-09 15:14:08 +00:00
|
|
|
|
|
|
|
using pfaedle::router::MOTs;
|
|
|
|
using pfaedle::osm::BBoxIdx;
|
|
|
|
using pfaedle::osm::OsmBuilder;
|
|
|
|
using pfaedle::config::MotConfig;
|
|
|
|
using pfaedle::config::Config;
|
|
|
|
using pfaedle::router::ShapeBuilder;
|
2019-01-10 15:52:59 +00:00
|
|
|
using configparser::ParseFileExc;
|
2018-06-09 15:14:08 +00:00
|
|
|
using pfaedle::config::MotConfigReader;
|
|
|
|
using pfaedle::config::ConfigReader;
|
|
|
|
using pfaedle::eval::Collector;
|
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
enum class RetCode {
|
|
|
|
SUCCESS = 0,
|
|
|
|
NO_INPUT_FEED = 1,
|
|
|
|
MULT_FEEDS_NOT_ALWD = 2,
|
|
|
|
TRIP_NOT_FOUND = 3,
|
|
|
|
GTFS_PARSE_ERR = 4,
|
|
|
|
NO_OSM_INPUT = 5,
|
|
|
|
MOT_CFG_PARSE_ERR = 6,
|
|
|
|
OSM_PARSE_ERR = 7,
|
|
|
|
GTFS_WRITE_ERR = 8,
|
|
|
|
NO_MOT_CFG = 9
|
|
|
|
};
|
|
|
|
|
2018-07-25 18:14:46 +00:00
|
|
|
std::string getFileNameMotStr(const MOTs& mots);
|
2019-01-10 15:52:59 +00:00
|
|
|
std::vector<std::string> getCfgPaths(const Config& cfg);
|
2018-06-09 15:14:08 +00:00
|
|
|
|
|
|
|
// _____________________________________________________________________________
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
// disable output buffering for standard output
|
|
|
|
setbuf(stdout, NULL);
|
|
|
|
|
|
|
|
// initialize randomness
|
|
|
|
srand(time(NULL) + rand()); // NOLINT
|
|
|
|
|
|
|
|
Config cfg;
|
|
|
|
MotConfigReader motCfgReader;
|
|
|
|
|
|
|
|
ConfigReader cr;
|
|
|
|
cr.read(&cfg, argc, argv);
|
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
std::vector<pfaedle::gtfs::Feed> gtfs(cfg.feedPaths.size());
|
2019-02-03 11:48:48 +00:00
|
|
|
// feed containing the shapes in memory for evaluation
|
2019-01-10 15:52:59 +00:00
|
|
|
ad::cppgtfs::gtfs::Feed evalFeed;
|
|
|
|
|
|
|
|
std::vector<std::string> cfgPaths = getCfgPaths(cfg);
|
2018-06-09 15:14:08 +00:00
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
try {
|
|
|
|
motCfgReader.parse(cfgPaths);
|
2019-02-11 16:55:05 +00:00
|
|
|
} catch (const configparser::ParseExc& ex) {
|
2019-01-10 15:52:59 +00:00
|
|
|
LOG(ERROR) << "Could not parse MOT configurations, reason was:";
|
|
|
|
std::cerr << ex.what() << std::endl;
|
|
|
|
exit(static_cast<int>(RetCode::MOT_CFG_PARSE_ERR));
|
|
|
|
}
|
2018-06-09 15:14:08 +00:00
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
if (cfg.osmPath.empty() && !cfg.writeOverpass) {
|
2018-07-24 17:33:18 +00:00
|
|
|
std::cerr << "No OSM input file specified (-x), see --help." << std::endl;
|
2019-01-10 15:52:59 +00:00
|
|
|
exit(static_cast<int>(RetCode::NO_OSM_INPUT));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (motCfgReader.getConfigs().size() == 0) {
|
|
|
|
LOG(ERROR) << "No MOT configurations specified and no implicit "
|
|
|
|
"configurations found, see --help.";
|
|
|
|
exit(static_cast<int>(RetCode::NO_MOT_CFG));
|
2018-07-24 17:33:18 +00:00
|
|
|
}
|
|
|
|
|
2018-06-09 15:14:08 +00:00
|
|
|
if (cfg.feedPaths.size() == 1) {
|
2019-01-10 15:52:59 +00:00
|
|
|
if (cfg.inPlace) cfg.outputPath = cfg.feedPaths[0];
|
|
|
|
if (!cfg.writeOverpass)
|
|
|
|
LOG(INFO) << "Reading " << cfg.feedPaths[0] << " ...";
|
|
|
|
try {
|
|
|
|
ad::cppgtfs::Parser p;
|
|
|
|
p.parse(>fs[0], cfg.feedPaths[0]);
|
|
|
|
if (cfg.evaluate) {
|
|
|
|
// read the shapes and store them in memory
|
|
|
|
p.parseShapes(&evalFeed, cfg.feedPaths[0]);
|
|
|
|
}
|
2019-02-11 16:55:05 +00:00
|
|
|
} catch (const ad::cppgtfs::ParserException& ex) {
|
2019-01-10 15:52:59 +00:00
|
|
|
LOG(ERROR) << "Could not parse input GTFS feed, reason was:";
|
|
|
|
std::cerr << ex.what() << std::endl;
|
|
|
|
exit(static_cast<int>(RetCode::GTFS_PARSE_ERR));
|
|
|
|
}
|
|
|
|
if (!cfg.writeOverpass) LOG(INFO) << "Done.";
|
|
|
|
} else if (cfg.writeOsm.size() || cfg.writeOverpass) {
|
|
|
|
for (size_t i = 0; i < cfg.feedPaths.size(); i++) {
|
|
|
|
if (!cfg.writeOverpass)
|
|
|
|
LOG(INFO) << "Reading " << cfg.feedPaths[i] << " ...";
|
|
|
|
ad::cppgtfs::Parser p;
|
|
|
|
try {
|
|
|
|
p.parse(>fs[i], cfg.feedPaths[i]);
|
2019-02-11 16:55:05 +00:00
|
|
|
} catch (const ad::cppgtfs::ParserException& ex) {
|
2019-01-10 15:52:59 +00:00
|
|
|
LOG(ERROR) << "Could not parse input GTFS feed, reason was:";
|
|
|
|
std::cerr << ex.what() << std::endl;
|
|
|
|
exit(static_cast<int>(RetCode::GTFS_PARSE_ERR));
|
|
|
|
}
|
|
|
|
if (!cfg.writeOverpass) LOG(INFO) << "Done.";
|
|
|
|
}
|
2018-06-09 15:14:08 +00:00
|
|
|
} else if (cfg.feedPaths.size() > 1) {
|
2019-01-10 15:52:59 +00:00
|
|
|
std::cerr << "Multiple feeds only allowed in filter mode." << std::endl;
|
|
|
|
exit(static_cast<int>(RetCode::MULT_FEEDS_NOT_ALWD));
|
2018-06-09 15:14:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LOG(DEBUG) << "Read " << motCfgReader.getConfigs().size()
|
|
|
|
<< " unique MOT configs.";
|
|
|
|
MOTs cmdCfgMots = cfg.mots;
|
2019-01-10 15:52:59 +00:00
|
|
|
pfaedle::gtfs::Trip* singleTrip = 0;
|
2018-06-09 15:14:08 +00:00
|
|
|
|
|
|
|
if (cfg.shapeTripId.size()) {
|
2019-01-10 15:52:59 +00:00
|
|
|
if (!cfg.feedPaths.size()) {
|
|
|
|
std::cout << "No input feed specified, see --help" << std::endl;
|
|
|
|
exit(static_cast<int>(RetCode::NO_INPUT_FEED));
|
|
|
|
}
|
|
|
|
singleTrip = gtfs[0].getTrips().get(cfg.shapeTripId);
|
2018-06-09 15:14:08 +00:00
|
|
|
if (!singleTrip) {
|
|
|
|
LOG(ERROR) << "Trip #" << cfg.shapeTripId << " not found.";
|
2019-01-10 15:52:59 +00:00
|
|
|
exit(static_cast<int>(RetCode::TRIP_NOT_FOUND));
|
2018-06-09 15:14:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cfg.writeOsm.size()) {
|
|
|
|
LOG(INFO) << "Writing filtered XML to " << cfg.writeOsm << " ...";
|
2019-01-10 15:52:59 +00:00
|
|
|
BBoxIdx box(BOX_PADDING);
|
|
|
|
for (size_t i = 0; i < cfg.feedPaths.size(); i++) {
|
|
|
|
ShapeBuilder::getGtfsBox(>fs[i], cmdCfgMots, cfg.shapeTripId, true,
|
|
|
|
&box);
|
|
|
|
}
|
|
|
|
OsmBuilder osmBuilder;
|
|
|
|
std::vector<pfaedle::osm::OsmReadOpts> opts;
|
|
|
|
for (const auto& o : motCfgReader.getConfigs()) {
|
|
|
|
if (std::find_first_of(o.mots.begin(), o.mots.end(), cmdCfgMots.begin(),
|
|
|
|
cmdCfgMots.end()) != o.mots.end()) {
|
|
|
|
opts.push_back(o.osmBuildOpts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
osmBuilder.filterWrite(cfg.osmPath, cfg.writeOsm, opts, box);
|
2019-02-11 16:55:05 +00:00
|
|
|
} catch (const xml::XmlFileException& ex) {
|
2019-01-10 15:52:59 +00:00
|
|
|
LOG(ERROR) << "Could not parse OSM data, reason was:";
|
|
|
|
std::cerr << ex.what() << std::endl;
|
|
|
|
exit(static_cast<int>(RetCode::OSM_PARSE_ERR));
|
|
|
|
}
|
|
|
|
exit(static_cast<int>(RetCode::SUCCESS));
|
|
|
|
} else if (cfg.writeOverpass) {
|
|
|
|
BBoxIdx box(BOX_PADDING);
|
|
|
|
for (size_t i = 0; i < cfg.feedPaths.size(); i++) {
|
|
|
|
ShapeBuilder::getGtfsBox(>fs[i], cmdCfgMots, cfg.shapeTripId, true,
|
|
|
|
&box);
|
2018-06-09 15:14:08 +00:00
|
|
|
}
|
|
|
|
OsmBuilder osmBuilder;
|
|
|
|
std::vector<pfaedle::osm::OsmReadOpts> opts;
|
|
|
|
for (const auto& o : motCfgReader.getConfigs()) {
|
|
|
|
if (std::find_first_of(o.mots.begin(), o.mots.end(), cmdCfgMots.begin(),
|
|
|
|
cmdCfgMots.end()) != o.mots.end()) {
|
|
|
|
opts.push_back(o.osmBuildOpts);
|
|
|
|
}
|
|
|
|
}
|
2019-01-10 15:52:59 +00:00
|
|
|
osmBuilder.overpassQryWrite(&std::cout, opts, box);
|
|
|
|
exit(static_cast<int>(RetCode::SUCCESS));
|
2018-07-24 17:33:18 +00:00
|
|
|
} else if (!cfg.feedPaths.size()) {
|
|
|
|
std::cout << "No input feed specified, see --help" << std::endl;
|
2019-01-10 15:52:59 +00:00
|
|
|
exit(static_cast<int>(RetCode::NO_INPUT_FEED));
|
2018-06-09 15:14:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<double> dfBins;
|
|
|
|
auto dfBinStrings = util::split(std::string(cfg.evalDfBins), ',');
|
|
|
|
for (auto st : dfBinStrings) dfBins.push_back(atof(st.c_str()));
|
|
|
|
Collector ecoll(cfg.evalPath, dfBins);
|
|
|
|
|
|
|
|
for (const auto& motCfg : motCfgReader.getConfigs()) {
|
2018-07-25 18:14:46 +00:00
|
|
|
std::string filePost;
|
2019-02-03 11:48:48 +00:00
|
|
|
auto usedMots = pfaedle::router::motISect(motCfg.mots, cmdCfgMots);
|
2018-06-09 15:14:08 +00:00
|
|
|
if (!usedMots.size()) continue;
|
2019-01-10 15:52:59 +00:00
|
|
|
if (singleTrip && !usedMots.count(singleTrip->getRoute()->getType()))
|
|
|
|
continue;
|
2018-07-25 18:14:46 +00:00
|
|
|
if (motCfgReader.getConfigs().size() > 1)
|
|
|
|
filePost = getFileNameMotStr(usedMots);
|
2018-06-09 15:14:08 +00:00
|
|
|
|
2019-02-03 11:48:48 +00:00
|
|
|
std::string motStr = pfaedle::router::getMotStr(usedMots);
|
2018-06-09 15:14:08 +00:00
|
|
|
LOG(INFO) << "Calculating shapes for mots " << motStr;
|
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
try {
|
2019-02-03 11:48:48 +00:00
|
|
|
pfaedle::router::FeedStops fStops =
|
|
|
|
pfaedle::router::writeMotStops(>fs[0], usedMots, cfg.shapeTripId);
|
|
|
|
|
|
|
|
pfaedle::osm::Restrictor restr;
|
|
|
|
pfaedle::trgraph::Graph graph;
|
|
|
|
pfaedle::osm::OsmBuilder osmBuilder;
|
|
|
|
|
|
|
|
pfaedle::osm::BBoxIdx box(BOX_PADDING);
|
|
|
|
ShapeBuilder::getGtfsBox(>fs[0], cmdCfgMots, cfg.shapeTripId,
|
|
|
|
cfg.dropShapes, &box);
|
|
|
|
|
|
|
|
if (fStops.size())
|
|
|
|
osmBuilder.read(cfg.osmPath, motCfg.osmBuildOpts, &graph, box,
|
|
|
|
cfg.gridSize, &fStops, &restr);
|
|
|
|
|
|
|
|
// TODO(patrick): move this somewhere else
|
|
|
|
for (auto& feedStop : fStops) {
|
|
|
|
if (feedStop.second) {
|
|
|
|
feedStop.second->pl().getSI()->getGroup()->writePens(
|
|
|
|
motCfg.osmBuildOpts.trackNormzer,
|
|
|
|
motCfg.routingOpts.platformUnmatchedPen,
|
|
|
|
motCfg.routingOpts.stationDistPenFactor,
|
|
|
|
motCfg.routingOpts.nonOsmPen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
ShapeBuilder shapeBuilder(>fs[0], &evalFeed, cmdCfgMots, motCfg, &ecoll,
|
2019-02-03 11:48:48 +00:00
|
|
|
&graph, &fStops, &restr, cfg);
|
2019-01-10 15:52:59 +00:00
|
|
|
|
|
|
|
if (cfg.writeGraph) {
|
|
|
|
LOG(INFO) << "Outputting graph.json...";
|
|
|
|
util::geo::output::GeoGraphJsonOutput out;
|
|
|
|
mkdir(cfg.dbgOutputPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
|
|
std::ofstream fstr(cfg.dbgOutputPath + "/graph.json");
|
|
|
|
out.print(*shapeBuilder.getGraph(), fstr);
|
|
|
|
fstr.close();
|
|
|
|
}
|
2018-06-09 15:14:08 +00:00
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
if (singleTrip) {
|
|
|
|
LOG(INFO) << "Outputting path.json...";
|
|
|
|
mkdir(cfg.dbgOutputPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
|
|
std::ofstream pstr(cfg.dbgOutputPath + "/path.json");
|
|
|
|
util::geo::output::GeoJsonOutput o(pstr);
|
2018-06-09 15:14:08 +00:00
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
auto l = shapeBuilder.shapeL(singleTrip);
|
2018-06-09 15:14:08 +00:00
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
o.print(l, util::json::Dict{{"ver", "new"}});
|
|
|
|
o.flush();
|
|
|
|
pstr.close();
|
2018-06-09 15:14:08 +00:00
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
exit(static_cast<int>(RetCode::SUCCESS));
|
2018-06-09 15:14:08 +00:00
|
|
|
}
|
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
pfaedle::netgraph::Graph ng;
|
|
|
|
shapeBuilder.shape(&ng);
|
2018-06-09 15:14:08 +00:00
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
if (cfg.buildTransitGraph) {
|
|
|
|
util::geo::output::GeoGraphJsonOutput out;
|
|
|
|
LOG(INFO) << "Outputting trgraph" + filePost + ".json...";
|
|
|
|
mkdir(cfg.dbgOutputPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
|
|
std::ofstream fstr(cfg.dbgOutputPath + "/trgraph" + filePost + ".json");
|
|
|
|
out.print(ng, fstr);
|
|
|
|
fstr.close();
|
|
|
|
}
|
2019-02-11 16:55:05 +00:00
|
|
|
} catch (const xml::XmlFileException& ex) {
|
2019-01-10 15:52:59 +00:00
|
|
|
LOG(ERROR) << "Could not parse OSM data, reason was:";
|
|
|
|
std::cerr << ex.what() << std::endl;
|
|
|
|
exit(static_cast<int>(RetCode::OSM_PARSE_ERR));
|
2018-06-09 15:14:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cfg.evaluate) ecoll.printStats(&std::cout);
|
|
|
|
|
|
|
|
if (cfg.feedPaths.size()) {
|
2019-01-10 15:52:59 +00:00
|
|
|
try {
|
|
|
|
mkdir(cfg.outputPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
|
|
LOG(INFO) << "Writing output GTFS to " << cfg.outputPath << " ...";
|
|
|
|
pfaedle::gtfs::Writer w;
|
|
|
|
w.write(>fs[0], cfg.outputPath);
|
2019-02-11 16:55:05 +00:00
|
|
|
} catch (const ad::cppgtfs::WriterException& ex) {
|
2019-01-10 15:52:59 +00:00
|
|
|
LOG(ERROR) << "Could not write final GTFS feed, reason was:";
|
|
|
|
std::cerr << ex.what() << std::endl;
|
|
|
|
exit(static_cast<int>(RetCode::GTFS_WRITE_ERR));
|
|
|
|
}
|
2018-06-09 15:14:08 +00:00
|
|
|
}
|
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
return static_cast<int>(RetCode::SUCCESS);
|
2018-06-09 15:14:08 +00:00
|
|
|
}
|
|
|
|
|
2018-07-25 18:14:46 +00:00
|
|
|
// _____________________________________________________________________________
|
|
|
|
std::string getFileNameMotStr(const MOTs& mots) {
|
|
|
|
std::string motStr;
|
|
|
|
for (const auto& mot : mots) {
|
2019-01-10 15:52:59 +00:00
|
|
|
motStr += "-" + ad::cppgtfs::gtfs::flat::Route::getTypeString(mot);
|
2018-07-25 18:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return motStr;
|
|
|
|
}
|
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
// _____________________________________________________________________________
|
|
|
|
std::vector<std::string> getCfgPaths(const Config& cfg) {
|
|
|
|
if (cfg.configPaths.size()) return cfg.configPaths;
|
|
|
|
std::vector<std::string> ret;
|
|
|
|
|
2019-05-13 00:27:12 +00:00
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
// install prefix global configuration path, if available
|
|
|
|
{
|
|
|
|
auto path = std::string(INSTALL_PREFIX) +
|
2019-06-28 13:10:15 +00:00
|
|
|
std::string(CFG_DIR) + "/" + "pfaedle" + "/" +
|
2019-01-10 15:52:59 +00:00
|
|
|
CFG_FILE_NAME;
|
|
|
|
std::ifstream is(path);
|
|
|
|
|
|
|
|
LOG(DEBUG) << "Testing for config file at " << path;
|
|
|
|
if (is.good()) {
|
|
|
|
ret.push_back(path);
|
|
|
|
LOG(DEBUG) << "Found implicit config file " << path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// local user configuration path, if available
|
|
|
|
{
|
2019-06-28 13:10:15 +00:00
|
|
|
auto path = util::getHomeDir() + CFG_HOME_SUFFIX + "/" +
|
2019-01-10 15:52:59 +00:00
|
|
|
"pfaedle" + "/" + CFG_FILE_NAME;
|
|
|
|
std::ifstream is(path);
|
|
|
|
|
|
|
|
LOG(DEBUG) << "Testing for config file at " << path;
|
|
|
|
if (is.good()) {
|
|
|
|
ret.push_back(path);
|
|
|
|
LOG(DEBUG) << "Found implicit config file " << path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-13 22:11:15 +00:00
|
|
|
// free this here, as we use homedir in the block above
|
|
|
|
|
2019-01-10 15:52:59 +00:00
|
|
|
// CWD
|
|
|
|
{
|
|
|
|
char cwd[PATH_MAX];
|
|
|
|
if (getcwd(cwd, sizeof(cwd))) {
|
|
|
|
auto path = std::string(cwd) + "/" + CFG_FILE_NAME;
|
|
|
|
std::ifstream is(path);
|
|
|
|
|
|
|
|
LOG(DEBUG) << "Testing for config file at " << path;
|
|
|
|
if (is.good()) {
|
|
|
|
ret.push_back(path);
|
|
|
|
LOG(DEBUG) << "Found implicit config file " << path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|