qfile.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 **
4 ** Definition of QFile class
5 **
6 ** Created : 930831
7 **
8 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9 **
10 ** This file is part of the tools module of the Qt GUI Toolkit.
11 **
12 ** This file may be distributed under the terms of the Q Public License
13 ** as defined by Trolltech AS of Norway and appearing in the file
14 ** LICENSE.QPL included in the packaging of this file.
15 **
16 ** This file may be distributed and/or modified under the terms of the
17 ** GNU General Public License version 2 as published by the Free Software
18 ** Foundation and appearing in the file LICENSE.GPL included in the
19 ** packaging of this file.
20 **
21 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22 ** licenses may use this file in accordance with the Qt Commercial License
23 ** Agreement provided with the Software.
24 **
25 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27 **
28 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29 ** information about Qt Commercial License Agreements.
30 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
31 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
32 **
33 ** Contact info@trolltech.com if any conditions of this licensing are
34 ** not clear to you.
35 **
36 **********************************************************************/
37 
38 #ifndef QFILE_H
39 #define QFILE_H
40 
41 #ifndef QT_H
42 #include "qiodevice.h"
43 #include "qstring.h"
44 #include <stdio.h>
45 #endif // QT_H
46 
47 class QDir;
48 
49 
50 class Q_EXPORT QFile : public QIODevice // file I/O device class
51 {
52 public:
53  QFile();
54  QFile( const QString &name );
55  virtual ~QFile();
56 
57  QString name() const;
58  void setName( const QString &name );
59 
60  typedef QCString (*EncoderFn)( const QString &fileName );
61  typedef QString (*DecoderFn)( const QCString &localfileName );
62  static QCString encodeName( const QString &fileName );
63  static QString decodeName( const QCString &localFileName );
64  static void setEncodingFunction( EncoderFn );
65  static void setDecodingFunction( DecoderFn );
66 
67  bool exists() const;
68  static bool exists( const QString &fileName );
69 
70  bool remove();
71  static bool remove( const QString &fileName );
72 
73  bool open( int );
74  bool open( int, FILE * );
75  bool open( int, int );
76  void close();
77  void flush();
78 
79  uint size() const;
80  int at() const;
81  bool at( int );
82  bool atEnd() const;
83 
84  int readBlock( char *data, uint len );
85  int writeBlock( const char *data, uint len );
86  int writeBlock( const QByteArray& data )
87  { return QIODevice::writeBlock(data); }
88  int readLine( char *data, uint maxlen );
89  int readLine( QString &, uint maxlen );
90 
91  int getch();
92  int putch( int );
93  int ungetch( int );
94 
95  int handle() const;
96 
97  int64 pos() const;
98  int64 toEnd();
99  bool seek(int64 pos);
100 
101 protected:
103  FILE *fh;
104  int fd;
105  int length;
106  bool ext_f;
107  void * d;
108 
109 private:
110  void init();
112 
113 private: // Disabled copy constructor and operator=
114 #if defined(Q_DISABLE_COPY)
115  QFile( const QFile & );
116  QFile &operator=( const QFile & );
117 #endif
118 };
119 
120 
121 inline QString QFile::name() const
122 { return fn; }
123 
124 inline int QFile::at() const
125 { return ioIndex; }
126 
127 
128 #endif // QFILE_H
static QCString name
Definition: declinfo.cpp:673
Traverses directory structures and contents in a platform-independent way.
Definition: qdir.h:52
long long int64
Definition: qglobal.h:360
int length
Definition: qfile.h:105
virtual int ungetch(int)=0
virtual void close()=0
int at() const
Definition: qfile.h:124
static const int maxlen
Definition: qregexp.cpp:904
QString name() const
Definition: qfile.h:121
virtual bool atEnd() const
Definition: qiodevice.cpp:498
virtual int readBlock(char *data, uint maxlen)=0
QCString ungetchBuffer
Definition: qfile.h:111
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
init
Definition: train.py:42
virtual int writeBlock(const char *data, uint len)=0
int fd
Definition: qfile.h:104
bool exists(std::string path)
virtual int getch()=0
QAsciiDict< Entry > fn
fileName
Definition: dumpTree.py:9
QIODevice & operator=(const QIODevice &)
int writeBlock(const QByteArray &data)
Definition: qfile.h:86
void * d
Definition: qfile.h:107
virtual int readLine(char *data, uint maxlen)
Definition: qiodevice.cpp:581
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
virtual void flush()=0
bool ext_f
Definition: qfile.h:106
FILE * fh
Definition: qfile.h:103
The QIODevice class is the base class of I/O devices.
Definition: qiodevice.h:88
virtual bool open(int mode)=0
virtual int putch(int)=0
unsigned uint
Definition: qglobal.h:351
#define Q_EXPORT
Definition: qglobal.h:468
virtual uint size() const =0
virtual int at() const
Definition: qiodevice.cpp:471
QString fn
Definition: qfile.h:102
int ioIndex
Definition: qiodevice.h:141