Fix error handling

This commit is contained in:
Phillip 2015-11-14 00:47:05 -08:00
parent ab86e2195f
commit 64f34cc903
2 changed files with 12 additions and 1 deletions

View File

@ -57,7 +57,8 @@ void FileReader::open()
if (!m_fileHandle) if (!m_fileHandle)
{ {
atError("File not found '%s'", filename()); std::string _filename = filename();
atError("File not found '%s'", _filename.c_str());
setError(); setError();
return; return;
} }
@ -82,6 +83,9 @@ void FileReader::close()
void FileReader::seek(atInt64 pos, SeekOrigin origin) void FileReader::seek(atInt64 pos, SeekOrigin origin)
{ {
if (!isOpen())
return;
// check block position // check block position
if (m_blockSize > 0) if (m_blockSize > 0)
{ {

View File

@ -84,6 +84,13 @@ void FileWriter::close()
void FileWriter::seek(atInt64 pos, SeekOrigin origin) void FileWriter::seek(atInt64 pos, SeekOrigin origin)
{ {
if (!isOpen())
{
atError("Unable to seek in file, not open");
setError();
return;
}
if (fseeko64(m_fileHandle, pos, (int)origin) != 0) if (fseeko64(m_fileHandle, pos, (int)origin) != 0)
{ {
atError("Unable to seek in file"); atError("Unable to seek in file");