summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2008-05-10 17:55:53 +0000
committerDominik Wenger <domonoky@googlemail.com>2008-05-10 17:55:53 +0000
commit6e812b1d2e7941ee1f3e7abdbc2a2eba601f17e3 (patch)
tree0ef4e2bfc90eae6b6cf347eec98d5b71c18db44a
parentacccee479a2e0ef1b373c7de85a70abb816682c3 (diff)
downloadrockbox-6e812b1d2e7941ee1f3e7abdbc2a2eba601f17e3.tar.gz
rockbox-6e812b1d2e7941ee1f3e7abdbc2a2eba601f17e3.zip
rbutil: Upps, forgot 2 new files for creating a zip.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17441 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/rbutilqt/rbzip.cpp67
-rw-r--r--rbutil/rbutilqt/rbzip.h42
2 files changed, 109 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/rbzip.cpp b/rbutil/rbutilqt/rbzip.cpp
new file mode 100644
index 0000000000..9a1064d823
--- /dev/null
+++ b/rbutil/rbutilqt/rbzip.cpp
@@ -0,0 +1,67 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2008 by Dominik Wenger
10 * $Id: rbzip.cpp 17129 2008-04-15 21:25:57Z bluebrother $
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "rbzip.h"
21#include <QtCore>
22
23
24Zip::ErrorCode RbZip::createZip(QString zip,QString dir,ProgressloggerInterface *dp)
25{
26 m_logger = dp;
27 Zip::ErrorCode error = Ok;
28 m_curEntry = 1;
29 int numEntrys=0;
30
31 m_logger->addItem(tr("Creating Backup: %1").arg(zip),LOGINFO);
32 QCoreApplication::processEvents();
33
34 // get number of entrys in dir
35 QDirIterator it(dir, QDirIterator::Subdirectories);
36 while (it.hasNext())
37 {
38 it.next();
39 numEntrys++;
40 QCoreApplication::processEvents();
41 }
42 m_logger->setProgressMax(numEntrys);
43
44 //! create zip
45 error = Zip::createArchive(zip);
46 if(error != Ok)
47 return error;
48
49 //! add the content
50 error = Zip::addDirectory(dir);
51 if(error != Ok)
52 return error;
53
54 //! close zip
55 error = Zip::closeArchive();
56
57 return error;
58}
59
60void RbZip::progress()
61{
62 m_curEntry++;
63 m_logger->setProgressValue(m_curEntry);
64 QCoreApplication::processEvents(); // update UI
65}
66
67
diff --git a/rbutil/rbutilqt/rbzip.h b/rbutil/rbutilqt/rbzip.h
new file mode 100644
index 0000000000..c4f637500b
--- /dev/null
+++ b/rbutil/rbutilqt/rbzip.h
@@ -0,0 +1,42 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2008 by Dominik Wenger
10 * $Id: rbzip.h 16993 2008-04-06 18:12:56Z bluebrother $
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef RBZIP_H
21#define RBZIP_H
22
23#include <QtCore>
24#include "zip/zip.h"
25
26#include "progressloggerinterface.h"
27
28class RbZip : public QObject, public Zip
29{
30 Q_OBJECT
31 public:
32 Zip::ErrorCode createZip(QString zip,QString dir,ProgressloggerInterface *dp);
33
34 virtual void progress();
35
36 private:
37 int m_curEntry;
38 ProgressloggerInterface *m_logger;
39};
40
41#endif
42