clang didnt like dynamic array
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
@@ -59,10 +60,11 @@ ssize_t readFile2(std::string path, char* buffer, size_t maxlen) {
|
||||
}
|
||||
|
||||
std::string readFile(std::string path, size_t trim) {
|
||||
char buf[trim + 2];
|
||||
char* buf = new char[trim + 2];
|
||||
ssize_t len = readFile2(path, buf, trim + 2);
|
||||
if (!len) return "0";
|
||||
std::string out(buf);
|
||||
delete[] buf;
|
||||
if (!len) return "0";
|
||||
return out.substr(0, len - 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user