File library fixes

This commit is contained in:
2025-10-06 18:00:09 +11:00
parent e89d7ffacc
commit e0ec910dc2

View File

@@ -22,17 +22,12 @@ Value modules::file(std::vector<Value> args) {
}
std::string buf;
std::string retval;
bool notfirst = false;
while (getline(file, buf)) {
if (notfirst) {
buf += "\n";
} else {
notfirst = true;
}
buf += "\n";
retval += buf;
}
file.close();
return Value(retval);
return Value("\"" + retval + "\"");
} else if (args[0].string_val == "readlines") {
std::ifstream file(args[1].string_val);
if (!file) {
@@ -42,7 +37,7 @@ Value modules::file(std::vector<Value> args) {
std::string buf;
std::vector<Value> retval;
while (getline(file, buf)) {
retval.push_back(Value(buf));
retval.push_back(Value("\"" + buf + "\""));
}
file.close();
return Value(retval);