|
|
@@ -1,34 +1,33 @@
|
|
|
module;
|
|
|
|
|
|
-#include <stdio.h>
|
|
|
-
|
|
|
-#include "ErrorSimulator.hpp"
|
|
|
+#include <cstdio>
|
|
|
|
|
|
module Core.File;
|
|
|
|
|
|
import Core.Logger;
|
|
|
+import ErrorSimulator;
|
|
|
|
|
|
using Core::LogLevel;
|
|
|
|
|
|
static bool readOpenFile(FILE* file, Core::List<char>& f, const char* path) {
|
|
|
- if(FAIL_STEP || fseek(file, 0, SEEK_END)) {
|
|
|
+ if(doFailStep() || fseek(file, 0, SEEK_END)) {
|
|
|
Core::report(LogLevel::ERROR, "cannot seek file end of '#'", path);
|
|
|
return true;
|
|
|
}
|
|
|
long l = ftell(file);
|
|
|
- if(FAIL_STEP || l < 0) {
|
|
|
+ if(doFailStep() || l < 0) {
|
|
|
Core::report(LogLevel::ERROR, "cannot tell file position of '#'", path);
|
|
|
return true;
|
|
|
}
|
|
|
size_t size = static_cast<size_t>(l);
|
|
|
f.resize(size + 1);
|
|
|
- if(FAIL_STEP || fseek(file, 0, SEEK_SET)) {
|
|
|
+ if(doFailStep() || fseek(file, 0, SEEK_SET)) {
|
|
|
Core::report(LogLevel::ERROR, "cannot seek file start of '#'", path);
|
|
|
return true;
|
|
|
}
|
|
|
size_t read = fread(&f[0], 1, size, file);
|
|
|
f.getLast() = 0;
|
|
|
- if(FAIL_STEP || read != size) {
|
|
|
+ if(doFailStep() || read != size) {
|
|
|
Core::report(
|
|
|
LogLevel::ERROR, "expected to read # bytes from '#' but read #",
|
|
|
size, path, read);
|
|
|
@@ -44,7 +43,7 @@ bool Core::readFile(List<char>& f, const char* path) {
|
|
|
return true;
|
|
|
}
|
|
|
bool r = readOpenFile(file, f, path);
|
|
|
- if(FAIL_STEP || fclose(file)) {
|
|
|
+ if(doFailStep() || fclose(file)) {
|
|
|
report(LogLevel::ERROR, "cannot close file '#'", path);
|
|
|
r = true;
|
|
|
}
|