Skip to content

Commit

Permalink
drop CAutoFile
Browse files Browse the repository at this point in the history
  • Loading branch information
ajtowns committed Nov 15, 2023
1 parent 80904f3 commit 273ad12
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 27 deletions.
24 changes: 0 additions & 24 deletions src/streams.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,30 +505,6 @@ class AutoFile
}
};

class CAutoFile : public AutoFile
{
private:
const int nVersion;

public:
explicit CAutoFile(std::FILE* file, int version, std::vector<std::byte> data_xor = {}) : AutoFile{file, std::move(data_xor)}, nVersion{version} {}
int GetVersion() const { return nVersion; }

template<typename T>
CAutoFile& operator<<(const T& obj)
{
::Serialize(*this, obj);
return (*this);
}

template<typename T>
CAutoFile& operator>>(T&& obj)
{
::Unserialize(*this, obj);
return (*this);
}
};

/** Wrapper around an AutoFile& that implements a ring buffer to
* deserialize from. It guarantees the ability to rewind a given number of bytes.
*
Expand Down
6 changes: 3 additions & 3 deletions src/test/streams_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor)
BOOST_AUTO_TEST_CASE(streams_buffered_file)
{
fs::path streams_test_filename = m_args.GetDataDirBase() / "streams_test_tmp";
CAutoFile file{fsbridge::fopen(streams_test_filename, "w+b"), 333};
AutoFile file{fsbridge::fopen(streams_test_filename, "w+b")};

// The value at each offset is the offset.
for (uint8_t j = 0; j < 40; ++j) {
Expand Down Expand Up @@ -380,7 +380,7 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file)
BOOST_AUTO_TEST_CASE(streams_buffered_file_skip)
{
fs::path streams_test_filename = m_args.GetDataDirBase() / "streams_test_tmp";
CAutoFile file{fsbridge::fopen(streams_test_filename, "w+b"), 333};
AutoFile file{fsbridge::fopen(streams_test_filename, "w+b")};
// The value at each offset is the byte offset (e.g. byte 1 in the file has the value 0x01).
for (uint8_t j = 0; j < 40; ++j) {
file << j;
Expand Down Expand Up @@ -433,7 +433,7 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file_rand)

fs::path streams_test_filename = m_args.GetDataDirBase() / "streams_test_tmp";
for (int rep = 0; rep < 50; ++rep) {
CAutoFile file{fsbridge::fopen(streams_test_filename, "w+b"), 333};
AutoFile file{fsbridge::fopen(streams_test_filename, "w+b")};
size_t fileSize = InsecureRandRange(256);
for (uint8_t i = 0; i < fileSize; ++i) {
file << i;
Expand Down

0 comments on commit 273ad12

Please sign in to comment.