#pragma once #include #include #include namespace kel { namespace lbm { class environment { public: std::string name; std::filesystem::path lbm_dir; std::filesystem::path data_dir; std::filesystem::path name_dir; public: }; template saw::error_or init_lbm_env(const saw::data& args){ namespace fs = std::filesystem; auto& args_n = args.template get<"args">(); auto& name = args_n.template get<"name">(); const char* home_dir = std::getenv("HOME"); if(not home_dir){ return saw::make_error("Couldn't find home dir"); } environment env; env.lbm_dir = std::filesystem::path{home_dir} / ".lbm"; { // Set default data location to "${lbm_dir}/data" env.data_dir = env.lbm_dir / "data"; // LBM Data Location auto lbm_dir_config = env.lbm_dir / "data_dir_location.txt"; if( fs::exists(lbm_dir_config) && fs::is_regular_file(lbm_dir_config) ){ std::ifstream file{lbm_dir_config}; if(file.is_open()){ std::stringstream buffer; buffer < output_directory(){ namespace fs = std::filesystem; const char* home_dir = std::getenv("HOME"); if(not home_dir){ return saw::make_error("Couldn't find home dir"); } auto lbm_dir = std::filesystem::path{home_dir} / ".lbm"; { auto lbm_dir_config = lbm_dir / "data_dir_location.txt"; if( fs::exists(lbm_dir_config) && fs::is_regular_file(lbm_dir_config) ){ std::ifstream file{lbm_dir_config}; if(file.is_open()){ std::stringstream buffer; buffer <