return 0 if cant read file
This commit is contained in:
@@ -55,6 +55,7 @@ ssize_t readFile2(std::string path, char* buffer, size_t maxlen) {
|
|||||||
std::string readFile(std::string path, size_t trim) {
|
std::string readFile(std::string path, size_t trim) {
|
||||||
char buf[trim + 2];
|
char buf[trim + 2];
|
||||||
ssize_t len = readFile2(path, buf, trim + 2);
|
ssize_t len = readFile2(path, buf, trim + 2);
|
||||||
|
if (!len) return "0";
|
||||||
std::string out(buf);
|
std::string out(buf);
|
||||||
return out.substr(0, len - 1);
|
return out.substr(0, len - 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user