Don't suppress IO errors when writing files
* Close or flush streams explicitely so writing is not deferred * to catch errors in the right place * to avoid suppressing errors completely when writing would be deferred to the destructor invocation * Improve comments
This commit is contained in:
parent
3afa954ebd
commit
fb8c99b2d4
|
@ -10,7 +10,7 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
||||||
set(META_APP_DESCRIPTION "C++ library to read/write passwords from/to encrypted files")
|
set(META_APP_DESCRIPTION "C++ library to read/write passwords from/to encrypted files")
|
||||||
set(META_VERSION_MAJOR 5)
|
set(META_VERSION_MAJOR 5)
|
||||||
set(META_VERSION_MINOR 0)
|
set(META_VERSION_MINOR 0)
|
||||||
set(META_VERSION_PATCH 1)
|
set(META_VERSION_PATCH 2)
|
||||||
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
|
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
|
||||||
|
|
||||||
# add project files
|
# add project files
|
||||||
|
|
|
@ -507,6 +507,7 @@ void PasswordFile::write(PasswordFileSaveFlags options)
|
||||||
if (!(options & PasswordFileSaveFlags::Encryption)) {
|
if (!(options & PasswordFileSaveFlags::Encryption)) {
|
||||||
// write data to file
|
// write data to file
|
||||||
m_file.write(decryptedData.data(), static_cast<streamsize>(size));
|
m_file.write(decryptedData.data(), static_cast<streamsize>(size));
|
||||||
|
m_file.flush();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,6 +561,7 @@ void PasswordFile::write(PasswordFileSaveFlags options)
|
||||||
}
|
}
|
||||||
m_file.write(reinterpret_cast<char *>(iv), aes256cbcIvSize);
|
m_file.write(reinterpret_cast<char *>(iv), aes256cbcIvSize);
|
||||||
m_file.write(encryptedData.data(), static_cast<streamsize>(outlen1 + outlen2));
|
m_file.write(encryptedData.data(), static_cast<streamsize>(outlen1 + outlen2));
|
||||||
|
m_file.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
Loading…
Reference in New Issue