diff --git a/src/Athena/FileReader.cpp b/src/Athena/FileReader.cpp index e788db8..5cdf8e3 100644 --- a/src/Athena/FileReader.cpp +++ b/src/Athena/FileReader.cpp @@ -57,7 +57,8 @@ void FileReader::open() if (!m_fileHandle) { - atError("File not found '%s'", filename()); + std::string _filename = filename(); + atError("File not found '%s'", _filename.c_str()); setError(); return; } @@ -82,6 +83,9 @@ void FileReader::close() void FileReader::seek(atInt64 pos, SeekOrigin origin) { + if (!isOpen()) + return; + // check block position if (m_blockSize > 0) { diff --git a/src/Athena/FileWriter.cpp b/src/Athena/FileWriter.cpp index abd3549..d6f579a 100644 --- a/src/Athena/FileWriter.cpp +++ b/src/Athena/FileWriter.cpp @@ -84,6 +84,13 @@ void FileWriter::close() 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) { atError("Unable to seek in file");