Adapt to changes in c++utilities

This commit is contained in:
Martchus 2019-06-10 22:44:29 +02:00
parent 0754760b19
commit b323460dbb
11 changed files with 30 additions and 33 deletions

View File

@ -9,8 +9,7 @@
#include <sstream> #include <sstream>
using namespace std; using namespace std;
using namespace IoUtilities; using namespace CppUtilities;
using namespace ConversionUtilities;
namespace Io { namespace Io {

View File

@ -5,8 +5,7 @@
#include <c++utilities/io/binarywriter.h> #include <c++utilities/io/binarywriter.h>
using namespace std; using namespace std;
using namespace IoUtilities; using namespace CppUtilities;
using namespace ConversionUtilities;
namespace Io { namespace Io {

View File

@ -24,8 +24,7 @@
#include <streambuf> #include <streambuf>
using namespace std; using namespace std;
using namespace ConversionUtilities; using namespace CppUtilities;
using namespace IoUtilities;
namespace Io { namespace Io {
@ -321,7 +320,7 @@ void PasswordFile::load()
if (remainingSize > numeric_limits<uLongf>::max()) { if (remainingSize > numeric_limits<uLongf>::max()) {
throw CryptoException("Size exceeds limit."); throw CryptoException("Size exceeds limit.");
} }
const auto rawDecompressedSize = ConversionUtilities::LE::toUInt64(decryptedData.data()); const auto rawDecompressedSize = LE::toUInt64(decryptedData.data());
if (rawDecompressedSize > numeric_limits<uLongf>::max()) { if (rawDecompressedSize > numeric_limits<uLongf>::max()) {
throw ParsingException("Decompressed size exceeds limit."); throw ParsingException("Decompressed size exceeds limit.");
} }
@ -477,7 +476,7 @@ void PasswordFile::write(PasswordFileSaveFlags options)
if (options & PasswordFileSaveFlags::Compression) { if (options & PasswordFileSaveFlags::Compression) {
uLongf compressedSize = compressBound(size); uLongf compressedSize = compressBound(size);
encryptedData.resize(8 + compressedSize); encryptedData.resize(8 + compressedSize);
ConversionUtilities::LE::getBytes(static_cast<std::uint64_t>(size), encryptedData.data()); LE::getBytes(static_cast<std::uint64_t>(size), encryptedData.data());
switch ( switch (
compress(reinterpret_cast<Bytef *>(encryptedData.data() + 8), &compressedSize, reinterpret_cast<Bytef *>(decryptedData.data()), size)) { compress(reinterpret_cast<Bytef *>(encryptedData.data() + 8), &compressedSize, reinterpret_cast<Bytef *>(decryptedData.data()), size)) {
case Z_MEM_ERROR: case Z_MEM_ERROR:
@ -685,7 +684,7 @@ void PasswordFile::setPath(const string &value)
m_path = value; m_path = value;
// support "file://" protocol // support "file://" protocol
if (ConversionUtilities::startsWith(m_path, "file:")) { if (startsWith(m_path, "file:")) {
m_path = m_path.substr(5); m_path = m_path.substr(5);
} }
} }

View File

@ -78,7 +78,7 @@ public:
PasswordFile(const PasswordFile &other); PasswordFile(const PasswordFile &other);
PasswordFile(PasswordFile &&other); PasswordFile(PasswordFile &&other);
~PasswordFile(); ~PasswordFile();
IoUtilities::NativeFileStream &fileStream(); CppUtilities::NativeFileStream &fileStream();
void open(PasswordFileOpenFlags options = PasswordFileOpenFlags::Default); void open(PasswordFileOpenFlags options = PasswordFileOpenFlags::Default);
void opened(); void opened();
void generateRootEntry(); void generateRootEntry();
@ -120,9 +120,9 @@ private:
std::unique_ptr<NodeEntry> m_rootEntry; std::unique_ptr<NodeEntry> m_rootEntry;
std::string m_extendedHeader; std::string m_extendedHeader;
std::string m_encryptedExtendedHeader; std::string m_encryptedExtendedHeader;
IoUtilities::NativeFileStream m_file; CppUtilities::NativeFileStream m_file;
IoUtilities::BinaryReader m_freader; CppUtilities::BinaryReader m_freader;
IoUtilities::BinaryWriter m_fwriter; CppUtilities::BinaryWriter m_fwriter;
std::uint32_t m_version; std::uint32_t m_version;
PasswordFileOpenFlags m_openOptions; PasswordFileOpenFlags m_openOptions;
PasswordFileSaveFlags m_saveOptions; PasswordFileSaveFlags m_saveOptions;
@ -131,7 +131,7 @@ private:
/*! /*!
* \brief Returns the underlying file stream. * \brief Returns the underlying file stream.
*/ */
inline IoUtilities::NativeFileStream &PasswordFile::fileStream() inline CppUtilities::NativeFileStream &PasswordFile::fileStream()
{ {
return m_file; return m_file;
} }

View File

@ -3,14 +3,14 @@
#include "./utils.h" #include "./utils.h"
#include <c++utilities/tests/testutils.h> #include <c++utilities/tests/testutils.h>
using namespace TestUtilities; using namespace CppUtilities;
#include <cppunit/TestFixture.h> #include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/HelperMacros.h>
using namespace std; using namespace std;
using namespace Io; using namespace Io;
using namespace TestUtilities::Literals; using namespace CppUtilities::Literals;
using namespace CPPUNIT_NS; using namespace CPPUNIT_NS;

View File

@ -4,14 +4,14 @@
#include "./utils.h" #include "./utils.h"
#include <c++utilities/tests/testutils.h> #include <c++utilities/tests/testutils.h>
using namespace TestUtilities; using namespace CppUtilities;
#include <cppunit/TestFixture.h> #include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/HelperMacros.h>
using namespace std; using namespace std;
using namespace Io; using namespace Io;
using namespace TestUtilities::Literals; using namespace CppUtilities::Literals;
using namespace CPPUNIT_NS; using namespace CPPUNIT_NS;

View File

@ -9,7 +9,7 @@
using namespace std; using namespace std;
using namespace Util; using namespace Util;
using namespace TestUtilities::Literals; using namespace CppUtilities::Literals;
using namespace CPPUNIT_NS; using namespace CPPUNIT_NS;

View File

@ -10,8 +10,8 @@
using namespace std; using namespace std;
using namespace Util::OpenSsl; using namespace Util::OpenSsl;
using namespace ConversionUtilities; using namespace CppUtilities;
using namespace TestUtilities::Literals; using namespace CppUtilities::Literals;
using namespace CPPUNIT_NS; using namespace CPPUNIT_NS;

View File

@ -9,8 +9,8 @@
using namespace std; using namespace std;
using namespace Io; using namespace Io;
using namespace TestUtilities::Literals; using namespace CppUtilities;
using namespace CppUtilities::Literals;
using namespace CPPUNIT_NS; using namespace CPPUNIT_NS;
/*! /*!
@ -49,8 +49,7 @@ void PasswordFileTests::tearDown()
*/ */
void PasswordFileTests::testReading() void PasswordFileTests::testReading()
{ {
testReading( testReading("read", testFilePath("testfile1.pwmgr"), "123456", testFilePath("testfile2.pwmgr"), string(), false, false);
"read", TestUtilities::testFilePath("testfile1.pwmgr"), "123456", TestUtilities::testFilePath("testfile2.pwmgr"), string(), false, false);
} }
void PasswordFileTests::testReading(const string &context, const string &testfile1path, const string &testfile1password, const string &testfile2, void PasswordFileTests::testReading(const string &context, const string &testfile1path, const string &testfile1password, const string &testfile2,
@ -153,8 +152,8 @@ void PasswordFileTests::testReading(const string &context, const string &testfil
*/ */
void PasswordFileTests::testBasicWriting() void PasswordFileTests::testBasicWriting()
{ {
const string testfile1 = TestUtilities::workingCopyPath("testfile1.pwmgr"); const string testfile1 = workingCopyPath("testfile1.pwmgr");
const string testfile2 = TestUtilities::workingCopyPath("testfile2.pwmgr"); const string testfile2 = workingCopyPath("testfile2.pwmgr");
PasswordFile file; PasswordFile file;
// resave testfile 1 // resave testfile 1
@ -187,8 +186,8 @@ void PasswordFileTests::testBasicWriting()
*/ */
void PasswordFileTests::testExtendedWriting() void PasswordFileTests::testExtendedWriting()
{ {
const string testfile1 = TestUtilities::workingCopyPath("testfile1.pwmgr"); const string testfile1 = workingCopyPath("testfile1.pwmgr");
const string testfile2 = TestUtilities::workingCopyPath("testfile2.pwmgr"); const string testfile2 = workingCopyPath("testfile2.pwmgr");
PasswordFile file; PasswordFile file;
// resave testfile 1 // resave testfile 1

View File

@ -9,11 +9,11 @@
#include <ostream> #include <ostream>
namespace TestUtilities { namespace CppUtilities {
inline std::ostream &operator<<(std::ostream &out, const Io::Entry *entry) inline std::ostream &operator<<(std::ostream &out, const Io::Entry *entry)
{ {
return out << ConversionUtilities::joinStrings(entry->path(), "/"); return out << joinStrings(entry->path(), "/");
} }
inline std::ostream &operator<<(std::ostream &out, const Io::Field *field) inline std::ostream &operator<<(std::ostream &out, const Io::Field *field)
@ -21,6 +21,6 @@ inline std::ostream &operator<<(std::ostream &out, const Io::Field *field)
return out << field->name() << '=' << field->value(); return out << field->name() << '=' << field->value();
} }
} // namespace TestUtilities } // namespace CppUtilities
#endif // PASSWORDFILE_TESTS_UTILS_H #endif // PASSWORDFILE_TESTS_UTILS_H

View File

@ -10,6 +10,7 @@
#include <string> #include <string>
using namespace std; using namespace std;
using namespace CppUtilities;
namespace Util { namespace Util {
@ -32,7 +33,7 @@ OpenSslRandomDevice::result_type OpenSslRandomDevice::operator()() const
{ {
unsigned char buf[4]; unsigned char buf[4];
if (RAND_bytes(buf, sizeof(buf))) { if (RAND_bytes(buf, sizeof(buf))) {
return ConversionUtilities::LE::toUInt32(reinterpret_cast<char *>(buf)); return LE::toUInt32(reinterpret_cast<char *>(buf));
} }
// handle error case // handle error case