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.");
|
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);
|
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);
|
m_file.seekg(0, ios_base::end);
|
||||||
if (m_file.tellg() == 0) {
|
if (m_file.tellg() == 0) {
|
||||||
throwIoFailure("File is empty.");
|
throwIoFailure("File is empty.");
|
||||||
|
|
|
@ -23,7 +23,9 @@ public:
|
||||||
PasswordFile(const PasswordFile &other);
|
PasswordFile(const PasswordFile &other);
|
||||||
PasswordFile(PasswordFile &&other);
|
PasswordFile(PasswordFile &&other);
|
||||||
~PasswordFile();
|
~PasswordFile();
|
||||||
|
IoUtilities::NativeFileStream &fileStream();
|
||||||
void open(bool readOnly = false);
|
void open(bool readOnly = false);
|
||||||
|
void opened();
|
||||||
void generateRootEntry();
|
void generateRootEntry();
|
||||||
void create();
|
void create();
|
||||||
void close();
|
void close();
|
||||||
|
@ -57,6 +59,15 @@ private:
|
||||||
IoUtilities::BinaryReader m_freader;
|
IoUtilities::BinaryReader m_freader;
|
||||||
IoUtilities::BinaryWriter m_fwriter;
|
IoUtilities::BinaryWriter m_fwriter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns the underlying file stream.
|
||||||
|
*/
|
||||||
|
inline IoUtilities::NativeFileStream &PasswordFile::fileStream()
|
||||||
|
{
|
||||||
|
return m_file;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Io
|
} // namespace Io
|
||||||
|
|
||||||
#endif // PASSWORD_FILE_IO_PASSWORD_FILE_H
|
#endif // PASSWORD_FILE_IO_PASSWORD_FILE_H
|
||||||
|
|
Loading…
Reference in New Issue