Allow to access underlying file stream directly
This commit is contained in:
parent
4c6a271eb8
commit
e265bbe733
|
@ -103,6 +103,16 @@ void PasswordFile::open(bool readOnly)
|
|||
throwIoFailure("Unable to open file because path is emtpy.");
|
||||
}
|
||||
m_file.open(m_path, readOnly ? ios_base::in | ios_base::binary : ios_base::in | ios_base::out | ios_base::binary);
|
||||
opened();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Handles the file being opened.
|
||||
*
|
||||
* Call this method after opening a file directly via the underlying fileStream().
|
||||
*/
|
||||
void PasswordFile::opened()
|
||||
{
|
||||
m_file.seekg(0, ios_base::end);
|
||||
if (m_file.tellg() == 0) {
|
||||
throwIoFailure("File is empty.");
|
||||
|
|
|
@ -23,7 +23,9 @@ public:
|
|||
PasswordFile(const PasswordFile &other);
|
||||
PasswordFile(PasswordFile &&other);
|
||||
~PasswordFile();
|
||||
IoUtilities::NativeFileStream &fileStream();
|
||||
void open(bool readOnly = false);
|
||||
void opened();
|
||||
void generateRootEntry();
|
||||
void create();
|
||||
void close();
|
||||
|
@ -57,6 +59,15 @@ private:
|
|||
IoUtilities::BinaryReader m_freader;
|
||||
IoUtilities::BinaryWriter m_fwriter;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Returns the underlying file stream.
|
||||
*/
|
||||
inline IoUtilities::NativeFileStream &PasswordFile::fileStream()
|
||||
{
|
||||
return m_file;
|
||||
}
|
||||
|
||||
} // namespace Io
|
||||
|
||||
#endif // PASSWORD_FILE_IO_PASSWORD_FILE_H
|
||||
|
|
Loading…
Reference in New Issue