Skip to content

Commit e63f643

Browse files
committed
streams: Base BufferedFile on AutoFile instead of CAutoFile
1 parent 98b0acd commit e63f643

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

src/streams.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ class CAutoFile : public AutoFile
529529
}
530530
};
531531

532-
/** Wrapper around a CAutoFile& that implements a ring buffer to
532+
/** Wrapper around an AutoFile& that implements a ring buffer to
533533
* deserialize from. It guarantees the ability to rewind a given number of bytes.
534534
*
535535
* Will automatically close the file when it goes out of scope if not null.
@@ -538,7 +538,7 @@ class CAutoFile : public AutoFile
538538
class BufferedFile
539539
{
540540
private:
541-
CAutoFile& m_src;
541+
AutoFile& m_src;
542542
uint64_t nSrcPos{0}; //!< how many bytes have been read from source
543543
uint64_t m_read_pos{0}; //!< how many bytes have been read from this
544544
uint64_t nReadLimit; //!< up to which position we're allowed to read
@@ -585,15 +585,13 @@ class BufferedFile
585585
}
586586

587587
public:
588-
BufferedFile(CAutoFile& file, uint64_t nBufSize, uint64_t nRewindIn)
588+
BufferedFile(AutoFile& file, uint64_t nBufSize, uint64_t nRewindIn)
589589
: m_src{file}, nReadLimit{std::numeric_limits<uint64_t>::max()}, nRewind{nRewindIn}, vchBuf(nBufSize, std::byte{0})
590590
{
591591
if (nRewindIn >= nBufSize)
592592
throw std::ios_base::failure("Rewind limit must be less than buffer size");
593593
}
594594

595-
int GetVersion() const { return m_src.GetVersion(); }
596-
597595
//! check whether we're at the end of the source file
598596
bool eof() const {
599597
return m_read_pos == nSrcPos && m_src.feof();

src/test/fuzz/buffered_file.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ FUZZ_TARGET(buffered_file)
2020
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
2121
FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
2222
std::optional<BufferedFile> opt_buffered_file;
23-
CAutoFile fuzzed_file{
23+
AutoFile fuzzed_file{
2424
fuzzed_file_provider.open(),
25-
0,
2625
ConsumeRandomLengthByteVector<std::byte>(fuzzed_data_provider),
2726
};
2827
try {
@@ -65,6 +64,5 @@ FUZZ_TARGET(buffered_file)
6564
});
6665
}
6766
opt_buffered_file->GetPos();
68-
opt_buffered_file->GetVersion();
6967
}
7068
}

src/test/streams_tests.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,6 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file)
271271
BufferedFile bf{file, 25, 10};
272272
BOOST_CHECK(!bf.eof());
273273

274-
// This member has no functional effect.
275-
BOOST_CHECK_EQUAL(bf.GetVersion(), 333);
276-
277274
uint8_t i;
278275
bf >> i;
279276
BOOST_CHECK_EQUAL(i, 0);

0 commit comments

Comments
 (0)