diff --git a/io/passwordfile.cpp b/io/passwordfile.cpp index 63c8a81..d2524b2 100644 --- a/io/passwordfile.cpp +++ b/io/passwordfile.cpp @@ -60,11 +60,28 @@ PasswordFile::PasswordFile(const string &path, const string &password) */ PasswordFile::PasswordFile(const PasswordFile &other) : m_path(other.m_path) + , m_rootEntry(other.m_rootEntry ? make_unique(*other.m_rootEntry) : nullptr) + , m_extendedHeader(other.m_extendedHeader) + , m_encryptedExtendedHeader(other.m_encryptedExtendedHeader) , m_freader(BinaryReader(&m_file)) , m_fwriter(BinaryWriter(&m_file)) { m_file.exceptions(ios_base::failbit | ios_base::badbit); - setPath(other.path()); + memcpy(m_password, other.m_password, 32); +} + +/*! + * \brief Moves the password file. + */ +PasswordFile::PasswordFile(PasswordFile &&other) + : m_path(move(other.m_path)) + , m_rootEntry(move(other.m_rootEntry)) + , m_extendedHeader(move(other.m_extendedHeader)) + , m_encryptedExtendedHeader(move(other.m_encryptedExtendedHeader)) + , m_file(move(other.m_file)) + , m_freader(BinaryReader(&m_file)) + , m_fwriter(BinaryWriter(&m_file)) +{ memcpy(m_password, other.m_password, 32); } @@ -73,7 +90,6 @@ PasswordFile::PasswordFile(const PasswordFile &other) */ PasswordFile::~PasswordFile() { - close(); } /*! diff --git a/io/passwordfile.h b/io/passwordfile.h index 6b81453..e1f3765 100644 --- a/io/passwordfile.h +++ b/io/passwordfile.h @@ -21,6 +21,7 @@ public: explicit PasswordFile(); explicit PasswordFile(const std::string &path, const std::string &password); PasswordFile(const PasswordFile &other); + PasswordFile(PasswordFile &&other); ~PasswordFile(); void open(bool readOnly = false); void generateRootEntry();