kwave  18.07.70
Kwave::RecoveryMapping Class Reference

#include <RecoveryMapping.h>

Inheritance diagram for Kwave::RecoveryMapping:
Inheritance graph
Collaboration diagram for Kwave::RecoveryMapping:
Collaboration graph

Public Member Functions

 RecoveryMapping (quint64 offset, quint64 length, QIODevice &dev, quint64 dev_offset)
 
virtual ~RecoveryMapping () Q_DECL_OVERRIDE
 
virtual qint64 read (quint64 offset, char *data, unsigned int bytes) Q_DECL_OVERRIDE
 
- Public Member Functions inherited from Kwave::RecoverySource
 RecoverySource (quint64 offset, quint64 length)
 
virtual ~RecoverySource ()
 
virtual quint64 offset () const
 
virtual quint64 length () const
 
virtual quint64 end () const
 

Private Attributes

QIODevice & m_dev
 
quint64 m_dev_offset
 

Detailed Description

Definition at line 29 of file RecoveryMapping.h.

Constructor & Destructor Documentation

◆ RecoveryMapping()

Kwave::RecoveryMapping::RecoveryMapping ( quint64  offset,
quint64  length,
QIODevice &  dev,
quint64  dev_offset 
)

Constructor

Parameters
offsetposition in the repaired file
lengthnumber of recovered bytes
devdamaged source/file
dev_offsetoffset within dev

Definition at line 25 of file RecoveryMapping.cpp.

30  m_dev(dev), m_dev_offset(dev_offset)
31 {
32 }
virtual quint64 length() const
virtual quint64 offset() const

◆ ~RecoveryMapping()

virtual Kwave::RecoveryMapping::~RecoveryMapping ( )
inlinevirtual

Destructor

Definition at line 43 of file RecoveryMapping.h.

References read().

43 {}
Here is the call graph for this function:

Member Function Documentation

◆ read()

qint64 Kwave::RecoveryMapping::read ( quint64  offset,
char *  data,
unsigned int  bytes 
)
virtual

implementation of Recoverysource::read

Implements Kwave::RecoverySource.

Definition at line 35 of file RecoveryMapping.cpp.

References Kwave::RecoverySource::end(), Kwave::RecoverySource::length(), m_dev, m_dev_offset, and Kwave::RecoverySource::offset().

Referenced by ~RecoveryMapping().

37 {
38  if (offset < this->offset()) return 0;
39  if (offset > end()) return 0;
40 
41  qint64 off = offset - this->offset();
42  qint64 len = length() - off;
43  if (bytes < len) len = bytes;
44  if (!len) return 0;
45 
46  if (!m_dev.seek(m_dev_offset + off)) return 0;
47  return m_dev.read(data, len);
48 }
virtual quint64 length() const
virtual quint64 end() const
virtual quint64 offset() const
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_dev

QIODevice& Kwave::RecoveryMapping::m_dev
private

source with the damaged file

Definition at line 52 of file RecoveryMapping.h.

Referenced by read().

◆ m_dev_offset

quint64 Kwave::RecoveryMapping::m_dev_offset
private

start offset in the damaged file

Definition at line 55 of file RecoveryMapping.h.

Referenced by read().


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