return 0 if cant read file

This commit is contained in:
drath
2025-09-14 09:09:59 +02:00
parent fd48556ff8
commit 89a94b1822

View File

@@ -55,6 +55,7 @@ ssize_t readFile2(std::string path, char* buffer, size_t maxlen) {
std::string readFile(std::string path, size_t trim) {
char buf[trim + 2];
ssize_t len = readFile2(path, buf, trim + 2);
if (!len) return "0";
std::string out(buf);
return out.substr(0, len - 1);
}