/usr/include/libktorrent/torrent/torrentfilestream.h is in libktorrent-dev 1.3.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | /***************************************************************************
* Copyright (C) 2010 by Joris Guisson *
* joris.guisson@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef BT_TORRENTFILESTREAM_H
#define BT_TORRENTFILESTREAM_H
#include <QIODevice>
#include <QWeakPointer>
#include <QSharedPointer>
#include <ktorrent_export.h>
#include <util/bitset.h>
#include <util/constants.h>
namespace bt
{
class ChunkManager;
class TorrentControl;
class TorrentInterface;
class ChunkSelectorDataProvider;
/**
QIODevice which streams a file of a torrent or the whole torrent (for single file torrents)
This object should not be manually constructed.
*/
class KTORRENT_EXPORT TorrentFileStream : public QIODevice
{
Q_OBJECT
public:
TorrentFileStream(TorrentControl* tc,ChunkManager* cman,bool streaming_mode,QObject* parent);
TorrentFileStream(TorrentControl* tc,Uint32 file_index,ChunkManager* cman,bool streaming_mode,QObject* parent);
virtual ~TorrentFileStream();
/// Open the device (only readonly access will be allowed)
virtual bool open(QIODevice::OpenMode mode);
/// Close the device
virtual void close();
/// Get the current stream position
virtual qint64 pos() const;
/// Get the total size
virtual qint64 size() const;
/// Seek, will fail if attempting to seek to a point which is not downloaded yet
virtual bool seek(qint64 pos);
/// Are we at the end of the file
virtual bool atEnd() const;
/// Reset the stream
virtual bool reset();
/// How many bytes are there available
virtual qint64 bytesAvailable() const;
/// The stream is not sequential
virtual bool isSequential() const {return false;}
/// Get the path of the file
QString path() const;
/// Get a BitSet of all the chunks of this TorrentFileStream
const BitSet & chunksBitSet() const;
/// Get the current chunk relative to the first chunk of the file
Uint32 currentChunk() const;
typedef QSharedPointer<TorrentFileStream> Ptr;
typedef QWeakPointer<TorrentFileStream> WPtr;
protected:
virtual qint64 writeData(const char* data, qint64 len);
virtual qint64 readData(char* data, qint64 maxlen);
void emitReadChannelFinished();
private slots:
void chunkDownloaded(bt::TorrentInterface* tc, bt::Uint32 chunk);
private:
class Private;
Private* d;
};
}
#endif // BT_TORRENTFILESTREAM_H
|