30 lines
841 B
C++
30 lines
841 B
C++
|
#include "parser.h"
|
||
|
#include <iostream>
|
||
|
#include "../settings.h"
|
||
|
#include <filesystem>
|
||
|
|
||
|
Parser::Parser() {}
|
||
|
|
||
|
std::vector<std::string> Parser::search_modules() {
|
||
|
std::string path = std::string(std::getenv("HOME")) + "/" + MODULES_DIR;
|
||
|
std::filesystem::directory_entry modules_dir(path);
|
||
|
|
||
|
if (!modules_dir.exists()) {
|
||
|
std::filesystem::create_directories(path);
|
||
|
std::cout << "No modules directory found. Created one at " << path << std::endl;
|
||
|
std::cout << "Please, download modules to that directory from my git." << std::endl;
|
||
|
}
|
||
|
|
||
|
std::vector<std::string> modules_files;
|
||
|
|
||
|
for (auto file : std::filesystem::directory_iterator(path)) {
|
||
|
modules_files.push_back(file.path());
|
||
|
}
|
||
|
|
||
|
return modules_files;
|
||
|
}
|
||
|
|
||
|
void Parser::set_module(std::string path) {
|
||
|
module = *(new Module(path));
|
||
|
}
|