Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qt/qfile.h 3.3.8 edited Jan 11 14:38 $ 00003 ** 00004 ** Definition of QFile class 00005 ** 00006 ** Created : 930831 00007 ** 00008 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 00009 ** 00010 ** This file is part of the tools module of the Qt GUI Toolkit. 00011 ** 00012 ** This file may be distributed under the terms of the Q Public License 00013 ** as defined by Trolltech ASA of Norway and appearing in the file 00014 ** LICENSE.QPL included in the packaging of this file. 00015 ** 00016 ** This file may be distributed and/or modified under the terms of the 00017 ** GNU General Public License version 2 as published by the Free Software 00018 ** Foundation and appearing in the file LICENSE.GPL included in the 00019 ** packaging of this file. 00020 ** 00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00022 ** licenses may use this file in accordance with the Qt Commercial License 00023 ** Agreement provided with the Software. 00024 ** 00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00027 ** 00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00029 ** information about Qt Commercial License Agreements. 00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00032 ** 00033 ** Contact info@trolltech.com if any conditions of this licensing are 00034 ** not clear to you. 00035 ** 00036 **********************************************************************/ 00037 00038 #ifndef QFILE_H 00039 #define QFILE_H 00040 00041 #ifndef QT_H 00042 #include "qiodevice.h" 00043 #include "qstring.h" 00044 #include <stdio.h> 00045 #endif // QT_H 00046 00047 class QDir; 00048 class QFilePrivate; 00049 00050 class Q_EXPORT QFile : public QIODevice // file I/O device class 00051 { 00052 public: 00053 QFile(); 00054 QFile( const QString &name ); 00055 ~QFile(); 00056 00057 QString name() const; 00058 void setName( const QString &name ); 00059 00060 typedef QCString (*EncoderFn)( const QString &fileName ); 00061 typedef QString (*DecoderFn)( const QCString &localfileName ); 00062 static QCString encodeName( const QString &fileName ); 00063 static QString decodeName( const QCString &localFileName ); 00064 static void setEncodingFunction( EncoderFn ); 00065 static void setDecodingFunction( DecoderFn ); 00066 00067 bool exists() const; 00068 static bool exists( const QString &fileName ); 00069 00070 bool remove(); 00071 static bool remove( const QString &fileName ); 00072 00073 bool open( int ); 00074 bool open( int, FILE * ); 00075 bool open( int, int ); 00076 void close(); 00077 void flush(); 00078 00079 Offset size() const; 00080 Offset at() const; 00081 bool at( Offset ); 00082 bool atEnd() const; 00083 00084 Q_LONG readBlock( char *data, Q_ULONG len ); 00085 Q_LONG writeBlock( const char *data, Q_ULONG len ); 00086 Q_LONG writeBlock( const QByteArray& data ) 00087 { return QIODevice::writeBlock(data); } 00088 Q_LONG readLine( char *data, Q_ULONG maxlen ); 00089 Q_LONG readLine( QString &, Q_ULONG maxlen ); 00090 00091 int getch(); 00092 int putch( int ); 00093 int ungetch( int ); 00094 00095 int handle() const; 00096 00097 QString errorString() const; // ### Qt 4: move into QIODevice 00098 00099 protected: 00100 void setErrorString( const QString& ); // ### Qt 4: move into QIODevice 00101 QString fn; 00102 FILE *fh; 00103 int fd; 00104 Offset length; 00105 bool ext_f; 00106 QFilePrivate *d; // ### Qt 4: make private 00107 00108 private: 00109 void init(); 00110 void setErrorStringErrno( int ); 00111 QCString ungetchBuffer; 00112 00113 private: // Disabled copy constructor and operator= 00114 #if defined(Q_DISABLE_COPY) 00115 QFile( const QFile & ); 00116 QFile &operator=( const QFile & ); 00117 #endif 00118 }; 00119 00120 00121 inline QString QFile::name() const 00122 { return fn; } 00123 00124 inline QIODevice::Offset QFile::at() const 00125 { return ioIndex; } 00126 00127 00128 #endif // QFILE_H