BmnRoot 26.10.0-233-gb9bbe585
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnFileReaderRaw.cxx
Go to the documentation of this file.
1// headers from this target
2#include "BmnFileReaderRaw.h"
3
4// o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
5// ================== BmnFileReaderZstd public methods ==================
6// o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
7
8BmnFileReaderRaw::BmnFileReaderRaw(const std::filesystem::path& aFilePath)
10 , fInputStream()
11 , fNextByteToRead(0ll)
12{
13 if (aFilePath.empty())
14 return;
15 Open(aFilePath);
16}
17
18// ========== BmnIFileReaderInterface ==========
19
20void BmnFileReaderRaw::Open(const std::filesystem::path& aFilePath)
21{
22 if (fInputStream.is_open()) {
23 LOG(error) << "Before opening a new stream with `BmnFileReaderRaw::Open`, close the old one!\n";
24 return;
25 }
27 return;
28 fInputStream.open(aFilePath, std::ios::in | std::ios::binary);
29}
30
32{
33 fInputStream.close();
34 fNextByteToRead = 0ll;
35}
36
37int64_t BmnFileReaderRaw::Read(void* dataToFill, const int64_t sizeToFill)
38{
39 fInputStream.read((char*)dataToFill, sizeToFill);
40 int64_t noOfReadBytes = fInputStream.gcount();
41 fNextByteToRead += noOfReadBytes;
42 return noOfReadBytes;
43}
44
45int64_t BmnFileReaderRaw::Tell() const noexcept
46{
47 return fNextByteToRead;
48}
49
50void BmnFileReaderRaw::Seek(int64_t value)
51{
52 if (fInputStream.bad())
53 return;
54 fInputStream.seekg(value);
55 if (fInputStream.good())
56 fNextByteToRead = value;
57}
58
59bool BmnFileReaderRaw::IsGood() const noexcept
60{
61 return fInputStream.good();
62}
63
64bool BmnFileReaderRaw::IsEOF() const noexcept
65{
66 return fInputStream.eof();
67}
68
73
74bool BmnFileReaderRaw::IsOpen() const noexcept
75{
76 return fInputStream.is_open();
77}
78
virtual bool IsOpen() const noexcept override
virtual BmnFileType GetFileType() const noexcept override
std::ifstream fInputStream
virtual void ClearStateFlags() override
virtual void Close() noexcept override
virtual int64_t Tell() const noexcept override
virtual void Open(const std::filesystem::path &aFilePath) override
virtual void Seek(int64_t value) override
BmnFileReaderRaw(const std::filesystem::path &aFilePath)
virtual bool IsEOF() const noexcept override
virtual bool IsGood() const noexcept override
virtual int64_t Read(void *dataToFill, const int64_t sizeToFill) override
BmnIFileReader()=default
bool PerformStandardChecksBeforeOpening(const std::filesystem::path &aFilePath) const noexcept