// $Id$ /************************************************************ * The Data Acquisition Backbone Core (DABC) * ************************************************************ * Copyright (C) 2009 - * * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * Planckstr. 1, 64291 Darmstadt, Germany * * Contact: http://dabc.gsi.de * ************************************************************ * This software can be used under the GPL license * * agreements as stated in LICENSE.txt file * * which is part of the distribution. * ************************************************************/ #include "dabc/BinaryFileIO.h" #include "dabc/logging.h" #include "dabc/MemoryPool.h" #include "dabc/Pointer.h" dabc::BinaryFileInput::BinaryFileInput(const dabc::Url& url) : FileInput(url), fFile(), fCurrentBufSize(0), fCurrentBufType(0) { } dabc::BinaryFileInput::~BinaryFileInput() { CloseFile(); } bool dabc::BinaryFileInput::Read_Init(const dabc::WorkerRef& wrk, const dabc::Command& cmd) { if (!dabc::FileInput::Read_Init(wrk, cmd)) return false; return OpenNextFile(); } bool dabc::BinaryFileInput::OpenNextFile() { CloseFile(); if (!TakeNextFileName()) return false; if (!fFile.OpenReading(CurrentFileName().c_str())) { EOUT("Cannot open file %s for reading", CurrentFileName().c_str()); return false; } DOUT1("Open bin file %s for reading", CurrentFileName().c_str()); return true; } bool dabc::BinaryFileInput::CloseFile() { fFile.Close(); ClearCurrentFileName(); return true; } unsigned dabc::BinaryFileInput::Read_Size() { if (!fFile.isReading()) return di_Error; fCurrentBufSize = 0; fCurrentBufType = 0; if (!fFile.ReadBufHeader(&fCurrentBufSize, &fCurrentBufType)) return di_Error; return fCurrentBufSize; } unsigned dabc::BinaryFileInput::Read_Complete(Buffer& buf) { if (!fFile.isReading()) return di_Error; if (buf.GetTotalSize()