PACK WOC  $VERSION$
mfile.h
Go to the documentation of this file.
1 // Copyright (C) 2009-2011 by Konrad Rosenbaum <konrad@silmor.de>
2 // protected under the GNU GPL version 3 or at your option any newer.
3 // See COPYING.GPL file that comes with this distribution.
4 //
5 
6 #ifndef WOC_MFILE_H
7 #define WOC_MFILE_H
8 
9 #include <QFile>
10 #include <QMap>
11 #include <QStringList>
12 
15 class MFile:public QFile
16 {
17  public:
19  MFile(QString name,QObject*parent=0);
21  MFile(QObject *parent=0);
23  ~MFile();
24 
26  virtual void close();
28  virtual bool open(QIODevice::OpenMode m=QIODevice::WriteOnly);
29 
31  QString fileName()const{return name;}
33  void setFileName(QString n);
34 
36  static bool touchedFile(QString);
37  private:
38  //flag to show whether file is open
39  bool isopen;
40  //original name of the file
41  QString name;
42 
43  //stores touched files
44  static QMap<QString,QStringList> touched;
45 };
46 
47 #endif
virtual void close()
compares the old (if it exists) and new version of the file and overwrites the old one if there are d...
Definition: mfile.cpp:20
overwrites QFile to only generate a file if its new version differs from an existing one...
Definition: mfile.h:15
static bool touchedFile(QString)
returns true if that file name has been touched yet
Definition: mfile.cpp:71
MFile(QString name, QObject *parent=0)
creates a new file (tentatively) with the given name (temporarily with ",new" appended) ...
Definition: mfile.cpp:13
virtual bool open(QIODevice::OpenMode m=QIODevice::WriteOnly)
opens the file, WriteOnly is assumed as mode
Definition: mfile.cpp:57
static QMap< QString, QStringList > touched
Definition: mfile.h:44
~MFile()
implicitly closes the file
Definition: mfile.cpp:15
void setFileName(QString n)
sets the file name for the file to be written; must be called before it is opened ...
Definition: mfile.cpp:51
QString fileName() const
returns the name of the file (without ",new")
Definition: mfile.h:31
QString name
Definition: mfile.h:41
bool isopen
Definition: mfile.h:39