libktorrent  2.2.0
dndfile.h
1 /***************************************************************************
2  * Copyright (C) 2005 by Joris Guisson *
3  * joris.guisson@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef BTDNDFILE_H
21 #define BTDNDFILE_H
22 
23 #include <QString>
24 #include <QSharedPointer>
25 #include <util/constants.h>
26 
27 namespace bt
28 {
29  class TorrentFile;
30 
37  class DNDFile
38  {
39  public:
40  DNDFile(const QString & path, const TorrentFile* tf, Uint32 chunk_size);
41  virtual ~DNDFile();
42 
44  void changePath(const QString & npath);
45 
49  void checkIntegrity();
50 
57  Uint32 readFirstChunk(Uint8* buf, Uint32 off, Uint32 size);
58 
65  Uint32 readLastChunk(Uint8* buf, Uint32 off, Uint32 size);
66 
73  void writeFirstChunk(const Uint8* buf, Uint32 off, Uint32 size);
74 
81  void writeLastChunk(const Uint8* buf, Uint32 off, Uint32 size);
82 
83  typedef QSharedPointer<DNDFile> Ptr;
84 
85  private:
86  void create();
87 
88  private:
89  QString path;
90  Uint32 first_size;
91  Uint32 last_size;
92  };
93 
94 }
95 
96 #endif
bt::DNDFile::writeFirstChunk
void writeFirstChunk(const Uint8 *buf, Uint32 off, Uint32 size)
bt::DNDFile::readFirstChunk
Uint32 readFirstChunk(Uint8 *buf, Uint32 off, Uint32 size)
bt::DNDFile::writeLastChunk
void writeLastChunk(const Uint8 *buf, Uint32 off, Uint32 size)
bt::DNDFile::checkIntegrity
void checkIntegrity()
bt::DNDFile::readLastChunk
Uint32 readLastChunk(Uint8 *buf, Uint32 off, Uint32 size)
bt::DNDFile::changePath
void changePath(const QString &npath)
Change the path of the file.