Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

blk_DiskBufferWriter Class Reference
[IVD Data format.]

#include <df.h>

Inheritance diagram for blk_DiskBufferWriter:
Inheritance graph
Collaboration diagram for blk_DiskBufferWriter:
Collaboration graph

List of all members.

Public Member Functions

 blk_DiskBufferWriter (df_BlockManager &a_mgr, const string &a_fName, const string &a_diskBufferFS, const ivd_FileSize_t a_diskBufferSize, bool a_append=false)
virtual ~blk_DiskBufferWriter ()

Private Member Functions

virtual void Seek (const UInt32_t a_offset)
 Seek forward for the specified number of bytes.
virtual void Write (const UInt8_t *a_data, const UInt32_t a_size)
 Write one block of data to disk buffer.

Private Attributes

cmn_File m_diskBuffer
UInt32_t m_seqNumber

Static Private Attributes

static UInt32_t m_numActive = 0
static cmn_Mutex m_numActive_x

Detailed Description

Definition at line 342 of file df.h.

Constructor & Destructor Documentation

blk_DiskBufferWriter::blk_DiskBufferWriter ( df_BlockManager a_mgr,
const string &  a_fName,
const string &  a_diskBufferFS,
const ivd_FileSize_t  a_diskBufferSize,
bool  a_append = false 

Definition at line 54 of file blk_diskbufferwriter.cpp.

References fom_CREATE_NEW, fom_OPEN_ALWAYS, fom_WRITE, log_FUNC_A_m, m_diskBuffer, m_numActive, m_numActive_x, m_seqNumber, cmn_File::OpenF(), cmn_File::SeekEndF(), cmn_File::SeekF(), and cmn_File::TruncF().

    : blk_BufferWriter(a_mgr),
      m_diskBuffer(g_cmn.dirs.diskbuf + a_diskBufferFS + a_fName, a_diskBufferSize),
      m_seqNumber(0) {

        "a_fName=" << a_fName <<
        ", a_append=" << boolalpha << a_append <<
        ", a_diskBufferSize=" << a_diskBufferSize);

    if (a_append) {
        m_diskBuffer.OpenF(fom_WRITE | fom_OPEN_ALWAYS);
    else {
        m_diskBuffer.OpenF(fom_WRITE | fom_CREATE_NEW);
        if (a_diskBufferSize > 0) {
            // Bug 8451: when a new file is created and the m_fileSize is given, the fileSize
            // is set upfront and a seek is done to the end of the file.
            // This procedure improved performance on Windows 2003

    cmn_MutexLock l(m_numActive_x);
    m_seqNumber = m_numActive;

Here is the call graph for this function:

blk_DiskBufferWriter::~blk_DiskBufferWriter (  )  [virtual]

Member Function Documentation

void blk_DiskBufferWriter::Seek ( const UInt32_t  a_offset  )  [private, virtual]

Seek forward for the specified number of bytes.

Used mainly to create sparse file if migration of a file is aborted.

Reimplemented from blk_BufferWriter.

Definition at line 100 of file blk_diskbufferwriter.cpp.

References dbg_DETAIL, log_DBG_m, log_FUNC_m, m_diskBuffer, and cmn_File::SeekRelF().


            "Seek forward for " << (a_offset/1024) << " kiB.");


Here is the call graph for this function:

void blk_DiskBufferWriter::Write ( const UInt8_t a_data,
const UInt32_t  a_size 
) [private, virtual]

Write one block of data to disk buffer.

Implements blk_BufferWriter.

Definition at line 112 of file blk_diskbufferwriter.cpp.

References cmn_ListDir(), dbg_DETAIL, cmn_File::GetCurrentPosF(), cmn_File::GetFullPathRef(), ie_NO_DISK_SPACE, ivd_Error, log_DBG_m, log_FUNC_m, log_WRN_m, m_diskBuffer, cmn_File::TruncF(), cmn_Path::UpPath(), and cmn_File::WriteF().


    // Atomic append to the file.
    // TODO: Shall this functionality be moved to cmn_File?

    ivd_FileRetSize_t wrote;
    try {
        wrote = m_diskBuffer.WriteF(a_data, a_size);
    catch (ivd_SysError) {
        cmn_FileInfo_t_v fileList_v;

        cmn_Path dbPath = m_diskBuffer.GetFullPathRef().UpPath();
        cmn_ListDir(dbPath, fileList_v);
        log_DBG_m(dbg_DETAIL, "Content of disk buffer: " <<
                              dbPath <<

    if (static_cast<UInt32_t>(wrote) < a_size) {
                "Writing failed. Truncating file to last full block: " <<
                m_diskBuffer.GetFullPathRef() );

        ivd_FilePosition_t filePos = m_diskBuffer.GetCurrentPosF();
        m_diskBuffer.TruncF(filePos - wrote);

        throw ivd_Error(ie_NO_DISK_SPACE, "Disk buffer out of space.");

Here is the call graph for this function:

Member Data Documentation

Reimplemented from blk_BufferWriter.

Definition at line 357 of file df.h.

Definition at line 359 of file df.h.

Referenced by blk_DiskBufferWriter(), Seek(), and Write().

Definition at line 360 of file df.h.

Referenced by blk_DiskBufferWriter(), and ~blk_DiskBufferWriter().

Definition at line 361 of file df.h.

Referenced by blk_DiskBufferWriter(), and ~blk_DiskBufferWriter().

Definition at line 363 of file df.h.

Referenced by blk_DiskBufferWriter().

The documentation for this class was generated from the following files: