diff options
Diffstat (limited to 'rbutil/rbutilqt/rbzip.cpp')
-rw-r--r-- | rbutil/rbutilqt/rbzip.cpp | 67 |
1 files changed, 67 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 | |||
24 | Zip::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 | |||
60 | void RbZip::progress() | ||
61 | { | ||
62 | m_curEntry++; | ||
63 | m_logger->setProgressValue(m_curEntry); | ||
64 | QCoreApplication::processEvents(); // update UI | ||
65 | } | ||
66 | |||
67 | |||