Fixes
This commit is contained in:
@ -126,16 +126,15 @@ namespace IACore
|
||||
|
||||
Expected<String, String> FileOps::ReadTextFile(IN CONST FilePath &path)
|
||||
{
|
||||
const auto f = fopen(path.c_str(), "rb");
|
||||
const auto f = fopen(path.c_str(), "r");
|
||||
if (!f)
|
||||
return MakeUnexpected(std::format("Failed to open file: {}", path.c_str()));
|
||||
String result;
|
||||
fseek(f, 0, SEEK_END);
|
||||
result.resize(ftell(f) + 1);
|
||||
result.resize(ftell(f));
|
||||
fseek(f, 0, SEEK_SET);
|
||||
fread(result.data(), 1, result.size() - 1, f);
|
||||
fread(result.data(), 1, result.size(), f);
|
||||
fclose(f);
|
||||
result.back() = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -158,7 +157,7 @@ namespace IACore
|
||||
{
|
||||
if (!overwrite && FileSystem::exists(path))
|
||||
return MakeUnexpected(std::format("File aready exists: {}", path.c_str()));
|
||||
const auto f = fopen(path.c_str(), "wb");
|
||||
const auto f = fopen(path.c_str(), "w");
|
||||
if (!f)
|
||||
return MakeUnexpected(std::format("Failed to write to file: {}", path.c_str()));
|
||||
const auto result = fwrite(contents.data(), 1, contents.size(), f);
|
||||
|
||||
@ -40,7 +40,10 @@ namespace IACore
|
||||
BOOL Logger::EnableLoggingToDisk(IN PCCHAR filePath)
|
||||
{
|
||||
if (s_logFile.is_open())
|
||||
return true;
|
||||
{
|
||||
s_logFile.flush();
|
||||
s_logFile.close();
|
||||
}
|
||||
s_logFile.open(filePath);
|
||||
return s_logFile.is_open();
|
||||
}
|
||||
|
||||
@ -61,8 +61,14 @@ namespace IACore
|
||||
#endif
|
||||
|
||||
handle->IsRunning = false;
|
||||
if (onFinishCallback)
|
||||
onFinishCallback(IA_MOVE(result));
|
||||
|
||||
if (!onFinishCallback)
|
||||
return;
|
||||
|
||||
if (!result)
|
||||
onFinishCallback(MakeUnexpected(result.error()));
|
||||
else
|
||||
onFinishCallback(*result);
|
||||
});
|
||||
|
||||
return handle;
|
||||
|
||||
Reference in New Issue
Block a user