kwave  18.07.70
RecoveryMapping.cpp
Go to the documentation of this file.
1 /*************************************************************************
2  RecoveryMapping.cpp - mapping of a recovered range in a audio file
3  -------------------
4  begin : Sun May 12 2002
5  copyright : (C) 2002 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "config.h"
19 
20 #include <QIODevice>
21 
22 #include "RecoveryMapping.h"
23 
24 //***************************************************************************
26  quint64 length,
27  QIODevice &dev,
28  quint64 dev_offset)
29  :Kwave::RecoverySource(offset, length),
30  m_dev(dev), m_dev_offset(dev_offset)
31 {
32 }
33 
34 //***************************************************************************
35 qint64 Kwave::RecoveryMapping::read(quint64 offset, char *data,
36  unsigned int bytes)
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 }
49 
50 //***************************************************************************
51 //***************************************************************************
RecoveryMapping(quint64 offset, quint64 length, QIODevice &dev, quint64 dev_offset)
virtual quint64 length() const
virtual quint64 end() const
Definition: App.h:33
virtual quint64 offset() const
virtual qint64 read(quint64 offset, char *data, unsigned int bytes) Q_DECL_OVERRIDE