Debian Codegraph @

src/plugin/test_folderlistmodel/regression/tempfiles.h

raw symbols SCIP
1 /**************************************************************************
2 *
3 * Copyright 2013 Canonical Ltd.
4 * Copyright 2013 Carlos J Mazieri <[email protected]>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * File: tempfiles.h
19 * Date: 4/2/2013
20 */
21
22 #ifndef TEMPFILES_H
23 #define TEMPFILES_H
24
25 #include <QStringList>
26
27 /*!
28 * \brief The TempFiles class easily creates some temporary files
29 *
30 * The current path starts with QDir::tempPath()
31 *
32 * By calling \ref addSubDirLevel() a directory is created under current path
33 *
34 * The \ref create() is used to create many files under current path
35 *
36 * removeAll() removes all files but not any directory created by addSubDirLevel()
37 */
38
39 class TempFiles
40 {
41 public:
42 TempFiles();
43 bool addSubDirLevel(const QString&dir);
44 bool create(int counter =1);
45 bool create(const QString& name, int counter = 1);
46 bool touch(int counter =1);
47 bool touch(const QString& name, int counter = 1);
48 QString lastFileCreated();
49 QString lastNameCreated();
50 QStringList createdList() const { return m_filesCreated; }
51 int created() const { return m_filesCreated.count();}
52 int howManyExist();
53 void removeAll();
54 QStringList createdNames();
55 QString lastPath() const { return m_dir; }
56 private:
57 bool createPrivate(const QString& name, int counter, bool putContent) ;
58 private:
59 QString m_dir;
60 QStringList m_filesCreated;
61 QByteArray m_content;
62 };
63
64
65 /*!
66 * \brief The DeepDir class creates a directory tree under QDir::tempPath()
67 *
68 * The constructor receives the name of the first directory and the level of the tree
69 * each subdirectory will have two files
70 *
71 * By calling \ref remove() the whole tree is removed.
72 */
73 class DeepDir
74 {
75 public:
76 DeepDir(const QString& rootDir, int level);
77 ~ DeepDir()
78 {
79 remove();
80 }
81 bool remove();
82 QString path() const { return root;}
83 QString firstLevel() const { return firstDirLevel; }
84 QString lastLevel() const { return lastDirLevel; }
85 int filesCreated() const { return totalFiles;}
86 int itemsCreated() const { return totalItems;}
87 private:
88 QString root;
89 QString firstDirLevel;
90 QString lastDirLevel;
91 int totalFiles;
92 int totalItems;
93 };
94
95 #endif // TEMPFILES_H