Blame qtools/qfile.h

Packit 1c1d7e
/****************************************************************************
Packit 1c1d7e
** 
Packit 1c1d7e
**
Packit 1c1d7e
** Definition of QFile class
Packit 1c1d7e
**
Packit 1c1d7e
** Created : 930831
Packit 1c1d7e
**
Packit 1c1d7e
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
Packit 1c1d7e
**
Packit 1c1d7e
** This file is part of the tools module of the Qt GUI Toolkit.
Packit 1c1d7e
**
Packit 1c1d7e
** This file may be distributed under the terms of the Q Public License
Packit 1c1d7e
** as defined by Trolltech AS of Norway and appearing in the file
Packit 1c1d7e
** LICENSE.QPL included in the packaging of this file.
Packit 1c1d7e
**
Packit 1c1d7e
** This file may be distributed and/or modified under the terms of the
Packit 1c1d7e
** GNU General Public License version 2 as published by the Free Software
Packit 1c1d7e
** Foundation and appearing in the file LICENSE.GPL included in the
Packit 1c1d7e
** packaging of this file.
Packit 1c1d7e
**
Packit 1c1d7e
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
Packit 1c1d7e
** licenses may use this file in accordance with the Qt Commercial License
Packit 1c1d7e
** Agreement provided with the Software.
Packit 1c1d7e
**
Packit 1c1d7e
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
Packit 1c1d7e
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Packit 1c1d7e
**
Packit 1c1d7e
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
Packit 1c1d7e
**   information about Qt Commercial License Agreements.
Packit 1c1d7e
** See http://www.trolltech.com/qpl/ for QPL licensing information.
Packit 1c1d7e
** See http://www.trolltech.com/gpl/ for GPL licensing information.
Packit 1c1d7e
**
Packit 1c1d7e
** Contact info@trolltech.com if any conditions of this licensing are
Packit 1c1d7e
** not clear to you.
Packit 1c1d7e
**
Packit 1c1d7e
**********************************************************************/
Packit 1c1d7e
Packit 1c1d7e
#ifndef QFILE_H
Packit 1c1d7e
#define QFILE_H
Packit 1c1d7e
Packit 1c1d7e
#ifndef QT_H
Packit 1c1d7e
#include "qiodevice.h"
Packit 1c1d7e
#include "qstring.h"
Packit 1c1d7e
#include <stdio.h>
Packit 1c1d7e
#endif // QT_H
Packit 1c1d7e
Packit 1c1d7e
class QDir;
Packit 1c1d7e
Packit 1c1d7e
Packit 1c1d7e
class Q_EXPORT QFile : public QIODevice			// file I/O device class
Packit 1c1d7e
{
Packit 1c1d7e
public:
Packit 1c1d7e
    QFile();
Packit 1c1d7e
    QFile( const QString &name );
Packit 1c1d7e
    virtual ~QFile();
Packit 1c1d7e
Packit 1c1d7e
    QString	name()	const;
Packit 1c1d7e
    void	setName( const QString &name );
Packit 1c1d7e
Packit 1c1d7e
    typedef QCString (*EncoderFn)( const QString &fileName );
Packit 1c1d7e
    typedef QString (*DecoderFn)( const QCString &localfileName );
Packit 1c1d7e
    static QCString encodeName( const QString &fileName );
Packit 1c1d7e
    static QString decodeName( const QCString &localFileName );
Packit 1c1d7e
    static void setEncodingFunction( EncoderFn );
Packit 1c1d7e
    static void setDecodingFunction( DecoderFn );
Packit 1c1d7e
Packit 1c1d7e
    bool	exists()   const;
Packit 1c1d7e
    static bool exists( const QString &fileName );
Packit 1c1d7e
Packit 1c1d7e
    bool	remove();
Packit 1c1d7e
    static bool remove( const QString &fileName );
Packit 1c1d7e
Packit 1c1d7e
    bool	open( int );
Packit 1c1d7e
    bool	open( int, FILE * );
Packit 1c1d7e
    bool	open( int, int );
Packit 1c1d7e
    void	close();
Packit 1c1d7e
    void	flush();
Packit 1c1d7e
Packit 1c1d7e
    uint	size()	const;
Packit 1c1d7e
    int		at()	const;
Packit 1c1d7e
    bool	at( int );
Packit 1c1d7e
    bool	atEnd() const;
Packit 1c1d7e
Packit 1c1d7e
    int		readBlock( char *data, uint len );
Packit 1c1d7e
    int		writeBlock( const char *data, uint len );
Packit 1c1d7e
    int		writeBlock( const QByteArray& data )
Packit 1c1d7e
		    { return QIODevice::writeBlock(data); }
Packit 1c1d7e
    int		readLine( char *data, uint maxlen );
Packit 1c1d7e
    int		readLine( QString &, uint maxlen );
Packit 1c1d7e
Packit 1c1d7e
    int		getch();
Packit 1c1d7e
    int		putch( int );
Packit 1c1d7e
    int		ungetch( int );
Packit 1c1d7e
Packit 1c1d7e
    int		handle() const;
Packit 1c1d7e
Packit 1c1d7e
    int64       pos() const;
Packit 1c1d7e
    int64       toEnd();
Packit 1c1d7e
    bool        seek(int64 pos);
Packit 1c1d7e
Packit 1c1d7e
protected:
Packit 1c1d7e
    QString	fn;
Packit 1c1d7e
    FILE       *fh;
Packit 1c1d7e
    int		fd;
Packit 1c1d7e
    int		length;
Packit 1c1d7e
    bool	ext_f;
Packit 1c1d7e
    void * 	d;
Packit 1c1d7e
Packit 1c1d7e
private:
Packit 1c1d7e
    void	init();
Packit 1c1d7e
    QCString ungetchBuffer;
Packit 1c1d7e
Packit 1c1d7e
private:	// Disabled copy constructor and operator=
Packit 1c1d7e
#if defined(Q_DISABLE_COPY)
Packit 1c1d7e
    QFile( const QFile & );
Packit 1c1d7e
    QFile &operator=( const QFile & );
Packit 1c1d7e
#endif
Packit 1c1d7e
};
Packit 1c1d7e
Packit 1c1d7e
Packit 1c1d7e
inline QString QFile::name() const
Packit 1c1d7e
{ return fn; }
Packit 1c1d7e
Packit 1c1d7e
inline int QFile::at() const
Packit 1c1d7e
{ return ioIndex; }
Packit 1c1d7e
Packit 1c1d7e
Packit 1c1d7e
#endif // QFILE_H