libktorrent  2.1.1
file.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 BTFILE_H
21 #define BTFILE_H
22 
23 #include <stdio.h>
24 #include <QSharedPointer>
25 #include <ktorrent_export.h>
26 #include "constants.h"
27 
28 namespace bt
29 {
30 
37  class KTORRENT_EXPORT File
38  {
39  FILE* fptr;
40  QString file;
41  public:
45  File();
46 
50  virtual ~File();
51 
58  bool open(const QString & file,const QString & mode);
59 
63  void close();
64 
68  void flush();
69 
77  Uint32 write(const void* buf,Uint32 size);
78 
86  Uint32 read(void* buf,Uint32 size);
87 
88  enum SeekPos
89  {
90  BEGIN,
91  END,
92  CURRENT
93  };
94 
101  Uint64 seek(SeekPos from,Int64 num);
102 
104  bool eof() const;
105 
107  Uint64 tell() const;
108 
110  QString errorString() const;
111 
112  typedef QSharedPointer<File> Ptr;
113  };
114 
115 }
116 
117 #endif