usestd::filesystem functions
This commit is contained in:
parent
5d0b36d0f0
commit
b7cbc64277
10
ml_util.cpp
10
ml_util.cpp
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
|
||||
const std::vector<std::string> commands {
|
||||
"eval", "type", "parse", "do", "if", "for", "while", "scope", "quote", "defn",
|
||||
|
|
@ -17,12 +18,11 @@ const std::vector<std::string> commands {
|
|||
};
|
||||
|
||||
std::string get_history_file_dir() {
|
||||
// TODO not portable and in function
|
||||
std::string file{"/.ml_history.txt"};
|
||||
std::string filename{".ml_history.txt"};
|
||||
const char *t = std::getenv("HOME");
|
||||
|
||||
if (t == nullptr) return "/tmp/" + file;
|
||||
else return std::string{t} + "/" + file;
|
||||
if (t == nullptr) return std::filesystem::temp_directory_path() / filename;
|
||||
else return std::filesystem::path(std::string{t}) /filename;
|
||||
}
|
||||
|
||||
MlEnvironment * repl_env = nullptr;
|
||||
|
|
@ -68,7 +68,7 @@ void completion(const char *buf, linenoiseCompletions *lc) {
|
|||
std::string token = str.substr(pos+1);
|
||||
std::string begining = str.substr(0, pos+1);
|
||||
|
||||
// TODO optimize not to get all lambdas, but those beginning with token
|
||||
// PERF optimize not to get all lambdas, but those beginning with token
|
||||
std::vector<std::string> lambdas = repl_env->get_lambdas_list();
|
||||
lambdas.insert(end(lambdas), begin(commands), end(commands));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue