Enhancements

Add mutex lock to prevent reading and writing a cached file at the same time.
Optimize codes.
This commit is contained in:
Tindy X committed 2020-03-01 01:58:59 +08:00
1 parent 6c2192b4f8
commit 1b6e877724
3 files changed
+10 -2

No files matched your search

+2 -1
View File
@@ -711,10 +711,11 @@ std::string fileGet(const std::string &path, bool scope_limit)
std::fseek(fp, 0, SEEK_END);
long tot = std::ftell(fp);
char *data = new char[tot + 1];
data[tot] = '\0';
std::rewind(fp);
std::fread(&data[0], 1, tot, fp);
std::fclose(fp);
content.append(data, 0, tot);
content.assign(data, tot);
delete[] data;
}