ktempfile.h
/*
This file is part of the KDE libraries
Copyright (c) 1999 Waldo Bastian <bastian@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _KTEMPFILE_H_
#define _KTEMPFILE_H_
#include <qstring.h>
#include <stdio.h>
#include <errno.h>
#include "kdelibs_export.h"
class QFile;
class QTextStream;
class QDataStream;
class KSaveFile;
class KTempFilePrivate;
class KDECORE_EXPORT KTempFile
{
friend class KSaveFile;
public:
KTempFile(QString filePrefix=QString::null,
QString fileExtension=QString::null,
int mode = 0600 );
~KTempFile();
void setAutoDelete(bool autoDelete) { bAutoDelete = autoDelete; }
int status() const;
QString name() const;
int handle() const;
FILE *fstream();
QTextStream *textStream();
QDataStream *dataStream();
QFile *file();
void unlink();
bool sync();
bool close();
protected:
KTempFile(bool);
bool create(const QString &filePrefix,
const QString &fileExtension, int mode);
void setError(int error) { mError = error; }
private:
int mError;
QString mTmpName;
int mFd;
FILE *mStream;
QFile *mFile;
QTextStream *mTextStream;
QDataStream *mDataStream;
bool bOpen;
bool bAutoDelete;
KTempFilePrivate *d;
};
#endif
KSaveFile::status
int status() const
Returns the status of the file based on errno.
Definition: ksavefile.h:68
KSaveFile::handle
int handle() const
An integer file descriptor open for writing to the file.
Definition: ksavefile.h:83
KTempFile::setAutoDelete
void setAutoDelete(bool autoDelete)
Turn automatic deletion on or off.
Definition: ktempfile.h:87
KSaveFile
The KSaveFile class has been made to write out changes to an existing file atomically.
Definition: ksavefile.h:41
KSaveFile::dataStream
QDataStream * dataStream()
A QDataStream* open for writing to the file.
Definition: ksavefile.h:115
KSaveFile::fstream
FILE * fstream()
A FILE* stream open for writing to the file.
Definition: ksavefile.h:91
KSaveFile::close
bool close()
Closes the file and makes the changes definitive.
Definition: ksavefile.cpp:107
KSaveFile::name
QString name() const
The name of the file as passed to the constructor.
Definition: ksavefile.cpp:94
KSaveFile::textStream
QTextStream * textStream()
A QTextStream* open for writing to the file.
Definition: ksavefile.h:107
KSaveFile::file
QFile * file()
A QFile* open for writing to the file.
Definition: ksavefile.h:99
KTempFile
The KTempFile class creates and opens a unique file for temporary use.
Definition: ktempfile.h:55

KDE Home | KDE Accessibility Home | Description of Access Keys