This commit is contained in:
@@ -21,6 +21,24 @@
|
||||
|
||||
namespace lm {
|
||||
|
||||
namespace {
|
||||
|
||||
bool isProjectRootDataPath(const std::filesystem::path& parent)
|
||||
{
|
||||
return parent.empty() || parent == std::filesystem::path(".");
|
||||
}
|
||||
|
||||
std::filesystem::path resolveDataPath(std::filesystem::path data_path)
|
||||
{
|
||||
if (!isProjectRootDataPath(data_path.parent_path()))
|
||||
return data_path;
|
||||
if (data_path.filename() == "state.json")
|
||||
return std::filesystem::path("data") / "state.json";
|
||||
return std::filesystem::path("data") / "RBS.db";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
LidarManagerApp::LidarManagerApp(int port,
|
||||
std::filesystem::path www_root,
|
||||
std::filesystem::path data_path)
|
||||
@@ -30,6 +48,7 @@ LidarManagerApp::LidarManagerApp(int port,
|
||||
|
||||
int LidarManagerApp::run()
|
||||
{
|
||||
data_path_ = resolveDataPath(data_path_);
|
||||
const std::filesystem::path data_dir = data_path_.parent_path();
|
||||
Database database(data_dir);
|
||||
std::string db_err;
|
||||
|
||||
Reference in New Issue
Block a user