Changed: Check return value of fwrite
This commit is contained in:
parent
3f8aa231a5
commit
4e9788116f
2 changed files with 25 additions and 6 deletions
|
@ -495,15 +495,30 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes
|
||||||
if (_NeedHeader)
|
if (_NeedHeader)
|
||||||
{
|
{
|
||||||
const char *hs = HeaderString();
|
const char *hs = HeaderString();
|
||||||
fwrite (hs, strlen (hs), 1, _FilePointer);
|
|
||||||
|
if (fwrite(hs, strlen(hs), 1, _FilePointer) != 1)
|
||||||
|
{
|
||||||
|
printf("Unable to write header: %s\n", hs);
|
||||||
|
}
|
||||||
|
|
||||||
_NeedHeader = false;
|
_NeedHeader = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!str.empty())
|
if (!str.empty())
|
||||||
fwrite (str.c_str(), str.size(), 1, _FilePointer);
|
{
|
||||||
|
if (fwrite(str.c_str(), str.size(), 1, _FilePointer) != 1)
|
||||||
|
{
|
||||||
|
printf("Unable to write string: %s\n", str.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!args.CallstackAndLog.empty())
|
if (!args.CallstackAndLog.empty())
|
||||||
fwrite (args.CallstackAndLog.c_str(), args.CallstackAndLog.size (), 1, _FilePointer);
|
{
|
||||||
|
if (fwrite(args.CallstackAndLog.c_str(), args.CallstackAndLog.size(), 1, _FilePointer) != 1)
|
||||||
|
{
|
||||||
|
printf("Unable to write call stack: %s\n", args.CallstackAndLog.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fflush (_FilePointer);
|
fflush (_FilePointer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1652,7 +1652,11 @@ void CClientEditionModule::saveUserComponentFile(const std::string& filename, bo
|
||||||
FILE* output = nlfopen(uncompressedName, "wb");
|
FILE* output = nlfopen(uncompressedName, "wb");
|
||||||
if (output)
|
if (output)
|
||||||
{
|
{
|
||||||
fwrite(component->UncompressedData, sizeof(char) , component->UncompressedDataLength, output);
|
if (fwrite(component->UncompressedData, sizeof(char), component->UncompressedDataLength, output) != component->UncompressedDataLength)
|
||||||
|
{
|
||||||
|
nlwarning("Unable to write %s", component->UncompressedData);
|
||||||
|
}
|
||||||
|
|
||||||
fclose(output);
|
fclose(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue