35 return OpenNextFile();
42 if (!TakeNextFileName())
return false;
44 if (!fFile.OpenReading(CurrentFileName().c_str())) {
45 EOUT(
"Cannot open file %s for reading", CurrentFileName().c_str());
49 DOUT1(
"Open bin file %s for reading", CurrentFileName().c_str());
58 ClearCurrentFileName();
64 if (!fFile.isReading())
return di_Error;
71 if (!fFile.ReadBufHeader(&fCurrentBufSize, &fCurrentBufType)) {
72 DOUT1(
"Error reading file %s", CurrentFileName().c_str());
76 return fCurrentBufSize;
81 if (!fFile.isReading())
return di_Error;
84 EOUT(
"Not enough space in buffer, required is %u", (
unsigned) fCurrentBufSize);
89 EOUT((
"Segmented buffer not supported - can be easily done"));
119 fFile.SetIO(fIO,
false);
121 return StartNewFile();
128 ProduceNewFileName();
130 if (!fFile.OpenWriting(CurrentFileName().c_str())) {
131 ShowInfo(-1,
dabc::format(
"%s cannot open file for writing", CurrentFileName().c_str()));
135 ShowInfo(0,
dabc::format(
"Open %s for writing", CurrentFileName().c_str()));
143 if (fFile.isWriting()) {
144 ShowInfo(0,
dabc::format(
"Close file %s", CurrentFileName().c_str()));
157 if (CheckBufferForNextFile(fullsz))
158 if (!StartNewFile()) {
159 EOUT(
"Cannot start new file for writing");
168 AccountBuffer(fullsz);
BinaryFileOutput(const dabc::Url &url)
virtual ~BinaryFileOutput()
virtual bool Write_Init()
This is generic virtual method to initialize output before real work is started.
virtual unsigned Write_Buffer(Buffer &buf)
Start writing of buffer to output.
Reference on memory from memory pool.
unsigned NumSegments() const
Returns number of segment in buffer.
unsigned SegmentSize(unsigned n=0) const
Returns size on the segment, no any boundary checks.
void SetTotalSize(BufferSize_t len)
Set total length of the buffer to specified value Size cannot be bigger than original size of the buf...
unsigned GetTypeId() const
BufferSize_t GetTotalSize() const
Return total size of all buffer segments.
void SetTypeId(unsigned tid)
void * SegmentPtr(unsigned n=0) const
Returns pointer on the segment, no any boundary checks.
Represents command with its arguments.
Interface for implementing file outputs.
virtual bool Write_Init()
This is generic virtual method to initialize output before real work is started.
bool null() const
Returns true if reference contains nullptr.
Uniform Resource Locator interpreter.
Reference on dabc::Worker
std::string format(const char *fmt,...)