<pre style='margin:0'>
Herby Gillot (herbygillot) pushed a commit to branch master
in repository macports-ports.
</pre>
<p><a href="https://github.com/macports/macports-ports/commit/d3849aadb852a3584877d5673ef29fe4eb22079a">https://github.com/macports/macports-ports/commit/d3849aadb852a3584877d5673ef29fe4eb22079a</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new d3849aadb85 libarchive-qt: new port
</span>d3849aadb85 is described below
<span style='display:block; white-space:pre;color:#808000;'>commit d3849aadb852a3584877d5673ef29fe4eb22079a
</span>Author: barracuda156 <vital.had@gmail.com>
AuthorDate: Tue Aug 29 11:21:31 2023 +0800
<span style='display:block; white-space:pre;color:#404040;'> libarchive-qt: new port
</span>---
archivers/libarchive-qt/Portfile | 55 +
...vert-Remove-Qt4-support-and-other-changes.patch | 11295 +++++++++++++++++++
2 files changed, 11350 insertions(+)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/archivers/libarchive-qt/Portfile b/archivers/libarchive-qt/Portfile
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 00000000000..d04ee0b9315
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/archivers/libarchive-qt/Portfile
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,55 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+PortSystem 1.0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+PortGroup gitlab 1.0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+PortGroup meson 1.0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+gitlab.setup marcusbritanicus libarchive-qt 2.0.8 v
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+revision 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+categories archivers devel
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+license GPL
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+maintainers {@barracuda156 gmail.com:vital.had} openmaintainer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+description Qt-based archiving solution with libarchive backend
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+long_description {*}${description}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+checksums rmd160 affe72bcc12197fc60ea3af86703f9b491632627 \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ sha256 4aadc3840279f8ad83ccaea653c01d97904d0de915bf98e1633ed8fdcd37434e \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ size 62840
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+depends_lib-append port:bzip2 \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ port:libarchive \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ port:lrzip \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ port:lzip \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ port:lzop \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ port:lzma \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ port:zlib
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+compiler.cxx_standard 2017
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+configure.args-append -Dinstall_static=false
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+variant qt4 description "Use Qt4" {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ PortGroup qt4 1.0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Qt4Core does not exist, should be QtCore.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ patchfiles-append 0001-Revert-Remove-Qt4-support-and-other-changes.patch
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ configure.args-append \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ -Duse_qt_version=qt4
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Needed to find qplatformdefs.h:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ configure.cppflags-append \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ -I${qt_share_dir}/mkspecs/common/posix
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+variant qt5 description "Use Qt5" {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ PortGroup qt5 1.0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ configure.args-append \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ -Duse_qt_version=qt5
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+if {![variant_isset qt4] && (${os.platform} eq "darwin" && ${os.major} > 10 || ${os.platform} ne "darwin")} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ default_variants +qt5
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+} else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ default_variants +qt4
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/archivers/libarchive-qt/files/0001-Revert-Remove-Qt4-support-and-other-changes.patch b/archivers/libarchive-qt/files/0001-Revert-Remove-Qt4-support-and-other-changes.patch
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 00000000000..061cdb56642
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/archivers/libarchive-qt/files/0001-Revert-Remove-Qt4-support-and-other-changes.patch
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,11295 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+From 56f5ea2e5054c4feb07a42a1973d64fc210a6c27 Mon Sep 17 00:00:00 2001
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+From: barracuda156 <vital.had@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Date: Tue, 29 Aug 2023 10:25:42 +0800
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Subject: [PATCH] Revert "Remove Qt4 support and other changes"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+This reverts commit be776bcad727ec55c543773f7b895eaa51905fb3.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+---
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ archiver/archiver.cpp | 407 +--
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ debian/changelog | 7 -
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/Global.hpp | 20 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/LibArchive.cpp | 3111 ++++++++++--------
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/LibBZip2.cpp | 157 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/LibBZip2.hpp | 27 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/LibGZip.cpp | 158 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/LibGZip.hpp | 25 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/LibLzma.cpp | 214 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/LibLzma.hpp | 25 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/LibLzma2.cpp | 226 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/LibLzma2.hpp | 25 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeDatabase.cpp | 704 ++++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeDatabase.hpp | 91 +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeDatabase_p.hpp | 87 +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeGlobPattern.cpp | 290 ++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeGlobPattern_p.hpp | 145 +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeMagicRule.cpp | 479 +++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeMagicRuleMatcher.cpp | 114 +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeMagicRuleMatcher_p.hpp | 76 +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeMagicRule_p.hpp | 87 +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeProvider.cpp | 1059 ++++++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeProvider_p.hpp | 163 +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeType.cpp | 537 +++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeType.hpp | 111 +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeTypeParser.cpp | 433 +++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeTypeParser_p.hpp | 116 +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/MimeHandler/NBMimeType_p.hpp | 111 +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/StandardPaths/NBStandardPaths.cpp | 306 ++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/StandardPaths/NBStandardPaths.hpp | 102 +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/StandardPaths/NBStandardPaths_unix.cpp | 322 ++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/libarchiveqt.h | 221 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/lz4dec.c | 552 ++--
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/lz4dec.h | 10 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lib/meson.build | 52 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ meson.build | 37 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ meson_options.txt | 2 +-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 37 files changed, 8153 insertions(+), 2456 deletions(-)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeDatabase.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeDatabase.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeDatabase_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeGlobPattern.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeGlobPattern_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeMagicRule.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeMagicRuleMatcher.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeMagicRuleMatcher_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeMagicRule_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeProvider.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeProvider_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeType.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeType.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeTypeParser.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeTypeParser_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/MimeHandler/NBMimeType_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/StandardPaths/NBStandardPaths.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/StandardPaths/NBStandardPaths.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ create mode 100644 lib/StandardPaths/NBStandardPaths_unix.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git archiver/archiver.cpp archiver/archiver.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 763aa39..b944d71 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- archiver/archiver.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ archiver/archiver.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,27 +1,27 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * Copyright 2018 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Copyright 2018 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // C++ Standard Library
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include <QCoreApplication>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -34,178 +34,205 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include "libarchiveqt.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* To pretty print file sizes */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-QString formatSize( qint64 num ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString total;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- const qint64 kb = 1024;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- const qint64 mb = 1024 * kb;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- const qint64 gb = 1024 * mb;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- const qint64 tb = 1024 * gb;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( num >= tb ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- total = QString( "%1 TiB" ).arg( QString::number( qreal( num ) / tb, 'f', 3 ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( num >= gb ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- total = QString( "%1 GiB" ).arg( QString::number( qreal( num ) / gb, 'f', 2 ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( num >= mb ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- total = QString( "%1 MiB" ).arg( QString::number( qreal( num ) / mb, 'f', 1 ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( num >= kb ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- total = QString( "%1 KiB" ).arg( QString::number( qreal( num ) / kb, 'f', 1 ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- total = QString( "%1 byte%2" ).arg( num ).arg( num > 1 ? "s": "" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return total;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString formatSize(qint64 num)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString total;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const qint64 kb = 1024;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const qint64 mb = 1024 * kb;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const qint64 gb = 1024 * mb;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const qint64 tb = 1024 * gb;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (num >= tb)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ total = QString("%1 TiB").arg(QString::number(qreal(num) / tb, 'f', 3));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (num >= gb)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ total = QString("%1 GiB").arg(QString::number(qreal(num) / gb, 'f', 2));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (num >= mb)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ total = QString("%1 MiB").arg(QString::number(qreal(num) / mb, 'f', 1));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (num >= kb)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ total = QString("%1 KiB").arg(QString::number(qreal(num) / kb, 'f', 1));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ total = QString("%1 byte%2").arg(num).arg(num > 1 ? "s": "");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return total;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* Pretty print the usage */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-void printUsage( const char *exec ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- std::cout << "Archiver " ARCHIVEQT_VERSION_STR "\n" << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- std::cout << "Usage:\n\t" << exec << " -c archive.xxx file1 file2 file3 ..." << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- std::cout << "\t" << exec << " -d archive.xxx output_dir" << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- std::cout << "\t" << exec << " -m archive.xxx member_name output_dir" << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- std::cout << "\t" << exec << " -l archive.xxx" << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void printUsage(const char *exec)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ std::cout << "Archiver v" ARCHIVEQT_VERSION_STR "\n" << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ std::cout << "Usage:\n\t" << exec << " -c archive.xxx file1 file2 file3 ..." << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ std::cout << "\t" << exec << " -d archive.xxx output_dir" << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ std::cout << "\t" << exec << " -m archive.xxx member_name output_dir" << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ std::cout << "\t" << exec << " -l archive.xxx" << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-int main( int argc, char **argv ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Init the QApplication instance */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QCoreApplication app( argc, argv );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * We need three arguments at minimum
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * 1. The program name (argv[ 0 ]) => Always existing
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * 2. The switch: one of c, d, m or l: Tells the program what to do
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * 3. The archive name to operate on (list or decompress)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * In case we are compressing or extracting a member, an additional argument is necessary
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( argc < 3 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- printUsage( argv[ 0 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Print help text or usage */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( (argc == 2) and (strcmp( argv[ 1 ], "-h" ) == 0) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- printUsage( argv[ 0 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Print help text or usage */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( (argc == 2) and (strcmp( argv[ 1 ], "--help" ) == 0) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- printUsage( argv[ 0 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Switch c, but no input files mentioned */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( (argc == 3) and (strcmp( argv[ 1 ], "-c" ) == 0) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- printUsage( argv[ 0 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- std::cout << "\nArchiver: ERROR: No input files specified." << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Switch m, but no member name mentioned */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( (argc < 4) and (strcmp( argv[ 1 ], "-m" ) == 0) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- printUsage( argv[ 0 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- std::cout << "\nArchiver: ERROR: No member name specified." << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Excess arguments */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( (argc > 3) and (strcmp( argv[ 1 ], "-l" ) == 0) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- printUsage( argv[ 0 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- std::cout << "\nArchiver: ERROR: Too many files specified" << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* No switch mentioned */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( (argc >= 3) and strcmp( argv[ 1 ], "-c" ) and strcmp( argv[ 1 ], "-d" ) and strcmp( argv[ 1 ], "-l" ) and strcmp( argv[ 1 ], "-m" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- printUsage( argv[ 0 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- std::cout << "\nArchiver: ERROR: You need to specify one of -c, -d, -m or -l" << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Compress the input files argv[3+] into archive argv[2] */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( strcmp( argv[ 1 ], "-c" ) == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Write archive code
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- LibArchiveQt *arc = new LibArchiveQt( argv[ 2 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- arc->updateInputFiles( app.arguments().mid( 3 ), LibArchiveQt::RelativeToCurrent );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- arc->createArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- arc->waitForFinished();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Decompress the archive argv[2] optionally to argv[3] */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( strcmp( argv[ 1 ], "-d" ) == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Read archive code
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- LibArchiveQt *arc = new LibArchiveQt( argv[ 2 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( argc >= 4 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- arc->setDestination( argv[ 3 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- arc->extractArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- arc->waitForFinished();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Decompress the member argv[3] optionally to argv[4] from archive argv[2] */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( strcmp( argv[ 1 ], "-m" ) == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Read archive code
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- LibArchiveQt *arc = new LibArchiveQt( argv[ 2 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( argc == 5 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- arc->setDestination( argv[ 3 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- arc->extractMember( argv[ 4 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- arc->extractMember( argv[ 3 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- arc->waitForFinished();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* List archive argv[2] */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( strcmp( argv[ 1 ], "-l" ) == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // List archive code
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- LibArchiveQt *arc = new LibArchiveQt( argv[ 2 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int length = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_FOREACH (ArchiveEntry *ae, arc->listArchive() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- length = (ae->name.length() > length ? ae->name.length() : length);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_FOREACH (ArchiveEntry *ae, arc->listArchive() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( ae->type == AE_IFREG ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << ae->name.rightJustified( length + 10 ).toLocal8Bit().data() << " " << formatSize( ae->size ).toLocal8Bit().data();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << ae->name.rightJustified( length + 10 ).toLocal8Bit().data();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- arc->waitForFinished();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Print help text */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- printUsage( argv[ 0 ] );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++int main(int argc, char **argv)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Init the QApplication instance */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QCoreApplication app(argc, argv);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * We need three arguments at minimum
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * 1. The program name (argv[ 0 ]) => Always existing
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * 2. The switch: one of c, d, m or l: Tells the program what to do
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * 3. The archive name to operate on (list or decompress)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * In case we are compressing or extracting a member, an additional argument is necessary
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (argc < 3)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ printUsage(argv[0]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Print help text or usage */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if ((argc == 2) and (strcmp(argv[1], "-h") == 0))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ printUsage(argv[0]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Print help text or usage */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if ((argc == 2) and (strcmp(argv[1], "--help") == 0))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ printUsage(argv[0]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Switch c, but no input files mentioned */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if ((argc == 3) and (strcmp(argv[1], "-c") == 0))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ printUsage(argv[0]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ std::cout << "\nArchiver: ERROR: No input files specified." << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Switch m, but no member name mentioned */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if ((argc < 4) and (strcmp(argv[1], "-m") == 0))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ printUsage(argv[0]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ std::cout << "\nArchiver: ERROR: No member name specified." << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Excess arguments */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if ((argc > 3) and (strcmp(argv[1], "-l") == 0))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ printUsage(argv[0]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ std::cout << "\nArchiver: ERROR: Too many files specified" << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* No switch mentioned */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if ((argc >= 3) and strcmp(argv[1], "-c") and strcmp(argv[1], "-d") and strcmp(argv[1], "-l") and strcmp(argv[1], "-m"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ printUsage(argv[0]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ std::cout << "\nArchiver: ERROR: You need to specify one of -c, -d, -m or -l" << std::endl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Compress the input files argv[3+] into archive argv[2] */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (strcmp(argv[1], "-c") == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Write archive code
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ LibArchiveQt *arc = new LibArchiveQt(argv[2]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ arc->updateInputFiles(app.arguments().mid(3), LibArchiveQt::RelativeToCurrent);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ arc->createArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ arc->waitForFinished();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Decompress the archive argv[2] optionally to argv[3] */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (strcmp(argv[1], "-d") == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Read archive code
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ LibArchiveQt *arc = new LibArchiveQt(argv[2]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (argc >= 4)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ arc->setDestination(argv[3]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ arc->extractArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ arc->waitForFinished();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Decompress the member argv[3] optionally to argv[4] from archive argv[2] */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (strcmp(argv[1], "-m") == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Read archive code
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ LibArchiveQt *arc = new LibArchiveQt(argv[2]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (argc == 5)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ arc->setDestination(argv[3]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ arc->extractMember(argv[4]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ arc->extractMember(argv[3]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ arc->waitForFinished();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* List archive argv[2] */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (strcmp(argv[1], "-l") == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // List archive code
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ LibArchiveQt *arc = new LibArchiveQt(argv[2]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int length = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_FOREACH (ArchiveEntry *ae, arc->listArchive())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ length = (ae->name.length() > length ? ae->name.length() : length);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_FOREACH (ArchiveEntry *ae, arc->listArchive())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ae->type == AE_IFREG)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << ae->name.rightJustified(length + 10).toLocal8Bit().data() << " " << formatSize(ae->size).toLocal8Bit().data();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << ae->name.rightJustified(length + 10).toLocal8Bit().data();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ arc->waitForFinished();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Print help text */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ printUsage(argv[0]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git debian/changelog debian/changelog
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index fab2911..35844c3 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- debian/changelog
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ debian/changelog
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,10 +1,3 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-libarchiveqt (2.0.8) unstable; urgency=medium
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * Remove Qt4 support
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * Remove Qt5/Qt6 deprecation warnings
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * Bump version number
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- -- Marcus Britanicus <marcusbritanicus@gmail.com> Thu, 04 Mar 2023 10:00:00 +0530
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ libarchiveqt (2.0.7) unstable; urgency=medium
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Fix meson-related bugs
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Bump version number
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/Global.hpp lib/Global.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index f6027f6..ba6d28a 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/Global.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/Global.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,6 +1,8 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-/**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * Global.hpp - Globally used header
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- **/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Global.hpp - Globally used header
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++*/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #pragma once
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -22,13 +24,13 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include <assert.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #if QT_VERSION >= 0x050000
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#include <QMimeDatabase>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#include <QMimeType>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#include <QStandardPaths>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #include <QMimeDatabase>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #include <QMimeType>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #include <QStandardPaths>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#include <NBMimeDatabase.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#include <NBMimeType.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#include <NBStandardPaths.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #include <NBMimeDatabase.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #include <NBMimeType.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #include <NBStandardPaths.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ static QMimeDatabase mimeDb;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/LibArchive.cpp lib/LibArchive.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index c58f242..abfe81b 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/LibArchive.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/LibArchive.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,19 +1,27 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-/**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * Copyright 2018 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- **/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Copyright 2018 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include "Global.hpp"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include "libarchiveqt.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -34,1588 +42,1793 @@ extern "C" {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include <assert.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include <libgen.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-inline static bool isDir( QString path ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct stat statbuf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( stat( path.toLocal8Bit().data(), &statbuf ) == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( S_ISDIR( statbuf.st_mode ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++inline static bool isDir(QString path)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct stat statbuf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (stat(path.toLocal8Bit().data(), &statbuf) == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (S_ISDIR(statbuf.st_mode))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-inline static QStringList recDirWalk( QString path ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QStringList fileList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++inline static QStringList recDirWalk(QString path)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList fileList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not isDir( path ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return fileList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not isDir(path))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return fileList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QDirIterator it( path, QDir::AllEntries | QDir::System | QDir::NoDotAndDotDot | QDir::Hidden, QDirIterator::Subdirectories );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QDirIterator it(path, QDir::AllEntries | QDir::System | QDir::NoDotAndDotDot | QDir::Hidden, QDirIterator::Subdirectories);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( it.hasNext() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- it.next();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (it.hasNext())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ it.next();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (it.fileInfo().isFile())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileList.append(it.fileInfo().filePath());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( it.fileInfo().isFile() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileList.append( it.fileInfo().filePath() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return fileList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return fileList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-inline static QString dirName( QString path ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( path.contains( "//" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- path = path.replace( "//", "/" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++inline static QString dirName(QString path)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (path.contains("//"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ path = path.replace("//", "/");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( path.endsWith( "/" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- path.chop( 1 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (path.endsWith("/"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ path.chop(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- char *dupPath = strdup( path.toLocal8Bit().constData() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString dirPth = QString( dirname( dupPath ) ) + "/";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char *dupPath = strdup(path.toLocal8Bit().constData());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString dirPth = QString(dirname(dupPath)) + "/";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- free( dupPath );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ free(dupPath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (dirPth == "//" ? "/" : dirPth);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(dirPth == "//" ? "/" : dirPth);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-inline static QString baseName( QString path ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( path.contains( "//" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- path = path.replace( "//", "/" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++inline static QString baseName(QString path)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (path.contains("//"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ path = path.replace("//", "/");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( path.endsWith( "/" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- path.chop( 1 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (path.endsWith("/"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ path.chop(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- char *dupPath = strdup( path.toLocal8Bit().constData() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString basePth = QString( basename( dupPath ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char *dupPath = strdup(path.toLocal8Bit().constData());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString basePth = QString(basename(dupPath));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- free( dupPath );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ free(dupPath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return basePth;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return basePth;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-inline static bool exists( QString path ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return not access( path.toLocal8Bit().constData(), F_OK );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++inline static bool exists(QString path)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return not access(path.toLocal8Bit().constData(), F_OK);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-inline static int mkpath( QString path, mode_t mode ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Root always exists */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( path == "/" ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++inline static int mkpath(QString path, mode_t mode)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Root always exists */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (path == "/")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* If the directory exists, thats okay for us */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( exists( path ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* If the directory exists, thats okay for us */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (exists(path))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* If the path is absolute, remove the leading '/' */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( path.startsWith( '/' ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- path.remove( 0, 1 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* If the path is absolute, remove the leading '/' */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (path.startsWith('/'))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ path.remove(0, 1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mkpath( dirName( path ), mode );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mkpath(dirName(path), mode);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return mkdir( path.toLocal8Bit().constData(), mode );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mkdir(path.toLocal8Bit().constData(), mode);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-inline static QString longestPath( QStringList& dirs ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QStringList paths;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++inline static QString longestPath(QStringList& dirs)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList paths;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_FOREACH (QString file, dirs) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- paths << QFileInfo( file ).absoluteFilePath();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_FOREACH (QString file, dirs)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ paths << QFileInfo(file).absoluteFilePath();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Get shortest path: Shortest path is the one with least number of '/' */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString shortest = paths.at( 0 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int count = 10240;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Get shortest path: Shortest path is the one with least number of '/' */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString shortest = paths.at(0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int count = 10240;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_FOREACH (QString path, paths) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( path.count( "/" ) < count ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- count = path.count( "/" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- shortest = path;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_FOREACH (QString path, paths)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (path.count("/") < count)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ count = path.count("/");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ shortest = path;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Remove the trailing '/' */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( shortest.endsWith( "/" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- shortest.chop( 1 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Remove the trailing '/' */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (shortest.endsWith("/"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ shortest.chop(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QFileInfo sDir( shortest );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFileInfo sDir(shortest);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( paths.filter( sDir.absoluteFilePath() ).length() != paths.length() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( sDir.absoluteFilePath() == "/" ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (paths.filter(sDir.absoluteFilePath()).count() != paths.count())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (sDir.absoluteFilePath() == "/")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- sDir = QFileInfo( sDir.absolutePath() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ sDir = QFileInfo(sDir.absolutePath());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return sDir.absoluteFilePath();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return sDir.absoluteFilePath();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-LibArchiveQt::LibArchiveQt( QString archive ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- readDone = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- isRunning = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mJob = NoJob;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- extractedMember = QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mExitStatus = 0; // 0 - Good, 1 - Bad
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++LibArchiveQt::LibArchiveQt(QString archive)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ readDone = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ isRunning = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mJob = NoJob;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ extractedMember = QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mExitStatus = 0; // 0 - Good, 1 - Bad
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveName = QDir( archive ).absolutePath();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveName = QDir(archive).absolutePath();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- setFilterFormat( mimeDb.mimeTypeForFile( archiveName ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ setFilterFormat(mimeDb.mimeTypeForFile(archiveName));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-QString LibArchiveQt::suffix( QString archiveName ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QMimeType mType = mimeDb.mimeTypeForFile( archiveName );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( mType == mimeDb.mimeTypeForFile( "file.cpio" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".cpio";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.shar" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".shar";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".tar";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.gz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (archiveName.endsWith( ".tar.gz" ) ? ".tar.gz" : ".tgz");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.grz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (archiveName.endsWith( ".tar.grz" ) ? ".tar.grz" : ".tgrz");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.xz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (archiveName.endsWith( ".tar.xz" ) ? ".tar.xz" : ".txz");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.lzo" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (archiveName.endsWith( ".tar.lzo" ) ? ".tar.lzo" : ".tlzo");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.lzma" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (archiveName.endsWith( ".tar.lzma" ) ? ".tar.lzma" : ".tlzma");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.lz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (archiveName.endsWith( ".tar.lz" ) ? ".tar.lz" : ".tlz");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.lrz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (archiveName.endsWith( ".tar.lrz" ) ? ".tar.lrz" : ".tlrz");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.lz4" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (archiveName.endsWith( ".tar.lz4" ) ? ".tar.lz4" : ".tlzo4");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.bz2" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (archiveName.endsWith( ".tar.bz2" ) ? ".tar.bz2" : ".tbz2");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.Z" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (archiveName.endsWith( ".tar.Z" ) ? ".tar.Z" : ".tZ");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.iso" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".iso";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.zip" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".zip";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.ar" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".ar";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.xar" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".xar";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.7z" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".7z";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.lz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".lz";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.lz4" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".lz4";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.uu" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".uu";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.lzo" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".lzo";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.gz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".gz";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.bz2" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".bz2";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.lzma" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".lzma";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.xz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ".xz";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return "";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString LibArchiveQt::suffix(QString archiveName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType mType = mimeDb.mimeTypeForFile(archiveName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (mType == mimeDb.mimeTypeForFile("file.cpio"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".cpio";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.shar"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".shar";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".tar";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.gz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(archiveName.endsWith(".tar.gz") ? ".tar.gz" : ".tgz");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.grz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(archiveName.endsWith(".tar.grz") ? ".tar.grz" : ".tgrz");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.xz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(archiveName.endsWith(".tar.xz") ? ".tar.xz" : ".txz");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.lzo"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(archiveName.endsWith(".tar.lzo") ? ".tar.lzo" : ".tlzo");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.lzma"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(archiveName.endsWith(".tar.lzma") ? ".tar.lzma" : ".tlzma");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.lz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(archiveName.endsWith(".tar.lz") ? ".tar.lz" : ".tlz");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.lrz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(archiveName.endsWith(".tar.lrz") ? ".tar.lrz" : ".tlrz");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.lz4"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(archiveName.endsWith(".tar.lz4") ? ".tar.lz4" : ".tlzo4");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.bz2"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(archiveName.endsWith(".tar.bz2") ? ".tar.bz2" : ".tbz2");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.Z"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(archiveName.endsWith(".tar.Z") ? ".tar.Z" : ".tZ");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.iso"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".iso";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.zip"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".zip";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.ar"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".ar";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.xar"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".xar";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.7z"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".7z";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.lz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".lz";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.lz4"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".lz4";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.uu"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".uu";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.lzo"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".lzo";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.gz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".gz";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.bz2"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".bz2";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.lzma"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".lzma";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.xz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ".xz";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return "";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-QStringList LibArchiveQt::supportedFormats() {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QStringList supported;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.cpio" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.shar" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.tar" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.tar.gz" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.tar.grz" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.tar.xz" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.tar.lzma" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.tar.lz4" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.tar.bz2" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.tar.Z" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.iso" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.zip" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.ar" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.xar" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.7z" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.lz" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.lz4" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.uu" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.lzo" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.gz" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.bz2" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.lzma" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << mimeDb.mimeTypeForFile( "file.xz" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString binary;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QStringList exeLocs = QString::fromLocal8Bit( qgetenv( "PATH" ) ).split( ":", Qt::SkipEmptyParts );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QStringList LibArchiveQt::supportedFormats()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList supported;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.cpio").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.shar").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.tar").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.tar.gz").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.tar.grz").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.tar.xz").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.tar.lzma").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.tar.lz4").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.tar.bz2").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.tar.Z").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.iso").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.zip").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.ar").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.xar").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.7z").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.lz").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.lz4").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.uu").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.lzo").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.gz").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.bz2").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.lzma").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << mimeDb.mimeTypeForFile("file.xz").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString binary;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList exeLocs = QString::fromLocal8Bit(qgetenv("PATH")).split(":", Qt::SkipEmptyParts);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QStringList exeLocs = QString::fromLocal8Bit( qgetenv( "PATH" ) ).split( ":", QString::SkipEmptyParts );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList exeLocs = QString::fromLocal8Bit(qgetenv("PATH")).split(":", QString::SkipEmptyParts);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString lzop = mimeDb.mimeTypeForFile( "file.lzo" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString lzip = mimeDb.mimeTypeForFile( "file.lz" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString lrzip = mimeDb.mimeTypeForFile( "file.lrz" ).name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_FOREACH (QString loc, exeLocs) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( exists( loc + "/lzip" ) and not supported.contains( lzip ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << lzip;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( exists( loc + "/lzop" ) and not supported.contains( lzop ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << lzop;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( exists( loc + "/lrzip" ) and not supported.contains( lrzip ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- supported << lrzip;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return supported;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString lzop = mimeDb.mimeTypeForFile("file.lzo").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString lzip = mimeDb.mimeTypeForFile("file.lz").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString lrzip = mimeDb.mimeTypeForFile("file.lrz").name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_FOREACH (QString loc, exeLocs)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (exists(loc + "/lzip") and not supported.contains(lzip))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << lzip;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (exists(loc + "/lzop") and not supported.contains(lzop))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << lzop;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (exists(loc + "/lrzip") and not supported.contains(lrzip))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ supported << lrzip;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return supported;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-void LibArchiveQt::createArchive() {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mJob = CreateArchive;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- isRunning = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void LibArchiveQt::createArchive()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mJob = CreateArchive;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ isRunning = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- start();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ start();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-void LibArchiveQt::extractArchive() {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mJob = ExtractArchive;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- isRunning = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void LibArchiveQt::extractArchive()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mJob = ExtractArchive;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ isRunning = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- start();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ start();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-void LibArchiveQt::extractMember( QString memberName ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- extractedMember = memberName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mJob = ExtractMember;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- isRunning = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void LibArchiveQt::extractMember(QString memberName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ extractedMember = memberName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mJob = ExtractMember;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ isRunning = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- start();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ start();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-ArchiveEntries LibArchiveQt::listArchive() {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( readDone ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return memberList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ArchiveEntries LibArchiveQt::listArchive()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (readDone)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return memberList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- memberList.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ memberList.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int r;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int r;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Source Archive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- a = archive_read_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_support_format_all( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_support_format_raw( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_support_filter_all( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Source Archive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ a = archive_read_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_support_format_all(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_support_format_raw(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_support_filter_all(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( (r = archive_read_open_filename( a, archiveName.toUtf8().data(), 10240 ) ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "[Error]" << archive_error_string( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- readDone = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return ArchiveEntries();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((r = archive_read_open_filename(a, archiveName.toUtf8().data(), 10240)))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "[Error]" << archive_error_string(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ readDone = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ArchiveEntries();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( true ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_read_next_header( a, &entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (true)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_read_next_header(a, &entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r == ARCHIVE_EOF ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r == ARCHIVE_EOF)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << archive_error_string( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << archive_error_string(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ArchiveEntry *ae = new ArchiveEntry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ae->name = archive_entry_pathname( entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ae->size = archive_entry_size( entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ae->type = archive_entry_filetype( entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- memcpy( &ae->info, archive_entry_stat( entry ), sizeof(struct stat) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ArchiveEntry *ae = new ArchiveEntry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ae->name = archive_entry_pathname(entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ae->size = archive_entry_size(entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ae->type = archive_entry_filetype(entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ memcpy(&ae->info, archive_entry_stat(entry), sizeof(struct stat));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- memberList << ae;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ memberList << ae;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_close( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_free( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_close(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_free(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- readDone = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ readDone = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return memberList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return memberList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-int LibArchiveQt::exitStatus() {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return mExitStatus;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++int LibArchiveQt::exitStatus()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mExitStatus;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-void LibArchiveQt::updateInputFiles( QStringList inFiles, LibArchiveQt::InputFileMode inMode ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not inFiles.length() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* First get the absolute filenames */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_FOREACH (QString file, inFiles) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( isDir( file ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- updateInputFiles( recDirWalk( file ), inMode );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QFileInfo info( file );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- switch ( inMode ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- case AbsolutePath: {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- inputList.insert( info.absoluteFilePath(), info.absoluteFilePath() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- case RelativeToRoot: {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- inputList.insert( info.absoluteFilePath(), QDir::root().relativeFilePath( info.absoluteFilePath() ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- case RelativeToHome: {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString relPath = QDir::home().relativeFilePath( info.absoluteFilePath() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( relPath.startsWith( "../" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- relPath.remove( 0, 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- inputList.insert( info.absoluteFilePath(), relPath );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- case RelativeToCurrent: {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString relPath = QDir::current().relativeFilePath( info.absoluteFilePath() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( relPath.startsWith( "../" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- relPath.remove( 0, 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- inputList.insert( info.absoluteFilePath(), relPath );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- case RelativeToWorkDir: {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* If @src is empty, set it to root */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- src = (src.isEmpty() ? "/" : src);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString relPath = QDir( src ).relativeFilePath( info.absoluteFilePath() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( relPath.startsWith( "../" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- relPath.remove( 0, 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- inputList.insert( info.absoluteFilePath(), relPath );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- case CommonRelativePath: {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString common;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( inFiles.length() == 1 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- common = dirName( inFiles.at( 0 ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- common = longestPath( inFiles );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString relPath = QDir( common ).relativeFilePath( info.absoluteFilePath() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( relPath.startsWith( "../" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- relPath.remove( 0, 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- inputList.insert( info.absoluteFilePath(), relPath );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- default: {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString relPath = QDir::current().relativeFilePath( info.absoluteFilePath() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( relPath.startsWith( "../" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- relPath.remove( 0, 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- inputList.insert( info.absoluteFilePath(), relPath );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void LibArchiveQt::updateInputFiles(QStringList inFiles, LibArchiveQt::InputFileMode inMode)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not inFiles.count())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* First get the absolute filenames */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_FOREACH (QString file, inFiles)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (isDir(file))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ updateInputFiles(recDirWalk(file), inMode);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFileInfo info(file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ switch (inMode)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case AbsolutePath:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inputList.insert(info.absoluteFilePath(), info.absoluteFilePath());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case RelativeToRoot:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inputList.insert(info.absoluteFilePath(), QDir::root().relativeFilePath(info.absoluteFilePath()));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case RelativeToHome:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString relPath = QDir::home().relativeFilePath(info.absoluteFilePath());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (relPath.startsWith("../"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ relPath.remove(0, 3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inputList.insert(info.absoluteFilePath(), relPath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case RelativeToCurrent:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString relPath = QDir::current().relativeFilePath(info.absoluteFilePath());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (relPath.startsWith("../"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ relPath.remove(0, 3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inputList.insert(info.absoluteFilePath(), relPath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case RelativeToWorkDir:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* If @src is empty, set it to root */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ src = (src.isEmpty() ? "/" : src);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString relPath = QDir(src).relativeFilePath(info.absoluteFilePath());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (relPath.startsWith("../"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ relPath.remove(0, 3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inputList.insert(info.absoluteFilePath(), relPath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case CommonRelativePath:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString common;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (inFiles.count() == 1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ common = dirName(inFiles.at(0));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ common = longestPath(inFiles);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString relPath = QDir(common).relativeFilePath(info.absoluteFilePath());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (relPath.startsWith("../"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ relPath.remove(0, 3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inputList.insert(info.absoluteFilePath(), relPath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ default:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString relPath = QDir::current().relativeFilePath(info.absoluteFilePath());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (relPath.startsWith("../"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ relPath.remove(0, 3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inputList.insert(info.absoluteFilePath(), relPath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-void LibArchiveQt::setWorkingDir( QString wDir ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- src = QString( wDir );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void LibArchiveQt::setWorkingDir(QString wDir)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ src = QString(wDir);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-void LibArchiveQt::setDestination( QString path ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * @p path will be a absolute.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * So QDir we construct will be home path
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = QString( path );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void LibArchiveQt::setDestination(QString path)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * @p path will be a absolute.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * So QDir we construct will be home path
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not QFileInfo( QDir( dest ).absolutePath() ).exists() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mkpath( path, 0755 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = QString(path);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not QFileInfo(QDir(dest).absolutePath()).exists())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mkpath(path, 0755);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "Extracting to:" << dest;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "Extracting to:" << dest;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-void LibArchiveQt::waitForFinished() {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not isRunning ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void LibArchiveQt::waitForFinished()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not isRunning)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QEventLoop eventLoop;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QEventLoop eventLoop;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #if QT_VERSION >= 0x050000
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- connect( this, &LibArchiveQt::jobFailed, &eventLoop, &QEventLoop::quit );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- connect( this, &LibArchiveQt::jobComplete, &eventLoop, &QEventLoop::quit );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ connect(this, &LibArchiveQt::jobFailed, &eventLoop, &QEventLoop::quit);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ connect(this, &LibArchiveQt::jobComplete, &eventLoop, &QEventLoop::quit);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- connect( this, SIGNAL(jobFailed()), &eventLoop, SLOT( quit() ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- connect( this, SIGNAL(jobComplete()), &eventLoop, SLOT( quit() ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ connect(this, SIGNAL(jobFailed()), &eventLoop, SLOT(quit()));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ connect(this, SIGNAL(jobComplete()), &eventLoop, SLOT(quit()));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- eventLoop.exec();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ eventLoop.exec();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-void LibArchiveQt::run() {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- switch ( mJob ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- case CreateArchive: {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( doCreateArchive() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mExitStatus = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- emit jobComplete();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mExitStatus = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- emit jobFailed();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- isRunning = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- case ExtractArchive: {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( doExtractArchive() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mExitStatus = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- emit jobComplete();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mExitStatus = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- emit jobFailed();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- isRunning = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- case ExtractMember: {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( doExtractMember( extractedMember ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mExitStatus = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- emit jobComplete();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mExitStatus = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- emit jobFailed();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- isRunning = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- case ListArchive: {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Nothing to run in the thread */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void LibArchiveQt::run()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ switch (mJob)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case CreateArchive:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (doCreateArchive())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mExitStatus = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ emit jobComplete();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mExitStatus = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ emit jobFailed();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ isRunning = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ExtractArchive:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (doExtractArchive())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mExitStatus = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ emit jobComplete();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mExitStatus = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ emit jobFailed();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ isRunning = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ExtractMember:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (doExtractMember(extractedMember))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mExitStatus = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ emit jobComplete();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mExitStatus = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ emit jobFailed();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ isRunning = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ListArchive:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Nothing to run in the thread */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-bool LibArchiveQt::doCreateArchive() {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct stat st;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- char buff[ 8192 ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int len;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int fd;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int r = ARCHIVE_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int errors = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int processed = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Prepare the workingDir */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( src.isEmpty() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- src = "/";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- a = archive_write_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Depend on the format provided by the user
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r |= archive_write_set_format( a, mArchiveFormat );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r |= archive_write_add_filter( a, mArchiveFilter );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "Cannot use the input filter/format.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_write_open_filename( a, archiveName.toUtf8().data() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "Unable to write file for writing.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_FOREACH (QString file, inputList.keys() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- char *filename = new char[ file.length() + 1 ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strcpy( filename, file.toUtf8().data() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( stat( filename, &st ) != 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- errors++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- printf( "[Error %d]: %s: %s\n", errno, strerror( errno ), filename );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- continue;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- char *arcPath = new char[ file.length() + 1 ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strcpy( arcPath, inputList.value( file ).toUtf8().data() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- entry = archive_entry_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_entry_set_pathname( entry, arcPath );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_entry_set_size( entry, st.st_size );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_entry_set_filetype( entry, st.st_mode );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_entry_set_perm( entry, st.st_mode );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_header( a, entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Perform the write
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fd = open( filename, O_RDONLY );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- len = read( fd, buff, sizeof(buff) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( len > 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_data( a, buff, len );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- len = read( fd, buff, sizeof(buff) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- close( fd );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_entry_free( entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- processed++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- emit progress( processed * 100 / inputList.count() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qApp->processEvents();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_close( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_free( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (errors ? false : true);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool LibArchiveQt::doCreateArchive()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct stat st;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char buff[8192];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int len;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int fd;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int r = ARCHIVE_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int errors = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int processed = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Prepare the workingDir */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (src.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ src = "/";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ a = archive_write_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Depend on the format provided by the user
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r |= archive_write_set_format(a, mArchiveFormat);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r |= archive_write_add_filter(a, mArchiveFilter);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "Cannot use the input filter/format.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_write_open_filename(a, archiveName.toUtf8().data());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "Unable to write file for writing.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_FOREACH (QString file, inputList.keys())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char *filename = new char[file.count() + 1];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strcpy(filename, file.toUtf8().data());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (stat(filename, &st) != 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ errors++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ printf("[Error %d]: %s: %s\n", errno, strerror(errno), filename);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ continue;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char *arcPath = new char[file.count() + 1];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strcpy(arcPath, inputList.value(file).toUtf8().data());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ entry = archive_entry_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_entry_set_pathname(entry, arcPath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_entry_set_size(entry, st.st_size);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_entry_set_filetype(entry, st.st_mode);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_entry_set_perm(entry, st.st_mode);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_header(a, entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Perform the write
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fd = open(filename, O_RDONLY);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ len = read(fd, buff, sizeof(buff));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (len > 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_data(a, buff, len);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ len = read(fd, buff, sizeof(buff));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ close(fd);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_entry_free(entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ processed++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ emit progress(processed * 100 / inputList.count());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qApp->processEvents();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_close(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_free(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(errors ? false : true);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-bool LibArchiveQt::doExtractArchive() {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( archiveType == None ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Change to the target directory
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- char srcDir[ 10240 ] = { 0 };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool LibArchiveQt::doExtractArchive()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (archiveType == None)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getcwd( srcDir, 10240 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Change to the target directory
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char srcDir[10240] = { 0 };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not dest.isEmpty() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int ret = chdir( dest.toUtf8().data() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ getcwd(srcDir, 10240);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( ret ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "chdir() failed:" << errno;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not dest.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int ret = chdir(dest.toUtf8().data());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ret)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "chdir() failed:" << errno;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( archiveType == Single ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QMimeType mType = mimeDb.mimeTypeForFile( archiveName );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (archiveType == Single)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType mType = mimeDb.mimeTypeForFile(archiveName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( mType == mimeDb.mimeTypeForFile( "file.lz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* LZip Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (mType == mimeDb.mimeTypeForFile("file.lz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* LZip Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString lzip;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString lzip;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QStringList exeLocs = QString::fromLocal8Bit( qgetenv( "PATH" ) ).split( ":", Qt::SkipEmptyParts );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList exeLocs = QString::fromLocal8Bit(qgetenv("PATH")).split(":", Qt::SkipEmptyParts);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QStringList exeLocs = QString::fromLocal8Bit( qgetenv( "PATH" ) ).split( ":", QString::SkipEmptyParts );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList exeLocs = QString::fromLocal8Bit(qgetenv("PATH")).split(":", QString::SkipEmptyParts);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_FOREACH (QString loc, exeLocs) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( exists( loc + "/lzip" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- lzip = loc + "/lzip";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not lzip.length() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "External program lzip not found.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive *ext;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int flags;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int r = ARCHIVE_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Select which attributes we want to restore. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags = ARCHIVE_EXTRACT_TIME;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_PERM;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_ACL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_FFLAGS;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Source Archive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- a = archive_read_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r |= archive_read_support_format_raw( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r |= archive_read_support_filter_program( a, QString( lzip + " -d" ).toLocal8Bit().data() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "Cannot use the input filter/format.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Structure to write files to disk
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ext = archive_write_disk_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_disk_set_options( ext, flags );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_disk_set_standard_lookup( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( (r = archive_read_open_filename( a, archiveName.toLocal8Bit().data(), 10240 ) ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "Unable to read archive:" << archive_error_string( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( true ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_read_next_header( a, &entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r == ARCHIVE_EOF ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "EOF";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( a ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( a ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_write_header( ext, entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( archive_entry_size( entry ) == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = copyData( a, ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_write_finish_entry( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_close( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_free( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_close( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_free( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.uu" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* UUEncode Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.lrz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* lrzip Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString lrzip;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QStringList exeLocs = QString::fromLocal8Bit( qgetenv( "PATH" ) ).split( ":", Qt::SkipEmptyParts );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_FOREACH (QString loc, exeLocs)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (exists(loc + "/lzip"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ lzip = loc + "/lzip";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not lzip.count())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "External program lzip not found.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive *ext;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int flags;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int r = ARCHIVE_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Select which attributes we want to restore. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags = ARCHIVE_EXTRACT_TIME;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_PERM;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_ACL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_FFLAGS;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Source Archive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ a = archive_read_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r |= archive_read_support_format_raw(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r |= archive_read_support_filter_program(a, QString(lzip + " -d").toLocal8Bit().data());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "Cannot use the input filter/format.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Structure to write files to disk
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ext = archive_write_disk_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_disk_set_options(ext, flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_disk_set_standard_lookup(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((r = archive_read_open_filename(a, archiveName.toLocal8Bit().data(), 10240)))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "Unable to read archive:" << archive_error_string(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (true)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_read_next_header(a, &entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r == ARCHIVE_EOF)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "EOF";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(a));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(a));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_write_header(ext, entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (archive_entry_size(entry) == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = copyData(a, ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_write_finish_entry(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_close(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_free(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_close(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_free(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.uu"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* UUEncode Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.lrz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* lrzip Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString lrzip;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList exeLocs = QString::fromLocal8Bit(qgetenv("PATH")).split(":", Qt::SkipEmptyParts);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QStringList exeLocs = QString::fromLocal8Bit( qgetenv( "PATH" ) ).split( ":", QString::SkipEmptyParts );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList exeLocs = QString::fromLocal8Bit(qgetenv("PATH")).split(":", QString::SkipEmptyParts);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_FOREACH (QString loc, exeLocs) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( exists( loc + "/lrzip" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- lrzip = loc + "/lrzip";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not lrzip.length() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "External program lrzip not found.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive *ext;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int flags;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int r = ARCHIVE_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Select which attributes we want to restore. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags = ARCHIVE_EXTRACT_TIME;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_PERM;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_ACL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_FFLAGS;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Source Archive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- a = archive_read_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r |= archive_read_support_format_raw( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r |= archive_read_support_filter_program( a, QString( lrzip + " -d" ).toLocal8Bit().data() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "Cannot use the input filter/format.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Structure to write files to disk
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ext = archive_write_disk_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_disk_set_options( ext, flags );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_disk_set_standard_lookup( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( (r = archive_read_open_filename( a, archiveName.toLocal8Bit().data(), 10240 ) ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "Unable to read archive:" << archive_error_string( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( true ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_read_next_header( a, &entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r == ARCHIVE_EOF ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "EOF";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( a ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( a ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_write_header( ext, entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( archive_entry_size( entry ) == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = copyData( a, ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_write_finish_entry( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_close( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_free( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_close( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_free( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.lzo" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* LZop Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString lzop;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QStringList exeLocs = QString::fromLocal8Bit( qgetenv( "PATH" ) ).split( ":", Qt::SkipEmptyParts );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_FOREACH (QString loc, exeLocs)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (exists(loc + "/lrzip"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ lrzip = loc + "/lrzip";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not lrzip.count())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "External program lrzip not found.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive *ext;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int flags;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int r = ARCHIVE_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Select which attributes we want to restore. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags = ARCHIVE_EXTRACT_TIME;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_PERM;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_ACL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_FFLAGS;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Source Archive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ a = archive_read_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r |= archive_read_support_format_raw(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r |= archive_read_support_filter_program(a, QString(lrzip + " -d").toLocal8Bit().data());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "Cannot use the input filter/format.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Structure to write files to disk
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ext = archive_write_disk_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_disk_set_options(ext, flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_disk_set_standard_lookup(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((r = archive_read_open_filename(a, archiveName.toLocal8Bit().data(), 10240)))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "Unable to read archive:" << archive_error_string(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (true)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_read_next_header(a, &entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r == ARCHIVE_EOF)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "EOF";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(a));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(a));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_write_header(ext, entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (archive_entry_size(entry) == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = copyData(a, ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_write_finish_entry(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_close(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_free(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_close(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_free(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.lzo"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* LZop Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString lzop;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList exeLocs = QString::fromLocal8Bit(qgetenv("PATH")).split(":", Qt::SkipEmptyParts);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QStringList exeLocs = QString::fromLocal8Bit( qgetenv( "PATH" ) ).split( ":", QString::SkipEmptyParts );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList exeLocs = QString::fromLocal8Bit(qgetenv("PATH")).split(":", QString::SkipEmptyParts);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_FOREACH (QString loc, exeLocs) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( exists( loc + "/lzop" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- lzop = loc + "/lzop";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not lzop.length() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "External program lzop not found.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive *ext;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int flags;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int r = ARCHIVE_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Select which attributes we want to restore. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags = ARCHIVE_EXTRACT_TIME;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_PERM;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_ACL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_FFLAGS;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Source Archive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- a = archive_read_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r |= archive_read_support_format_raw( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r |= archive_read_support_filter_program( a, QString( lzop + " -d" ).toLocal8Bit().data() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "Cannot use the input filter/format.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Structure to write files to disk
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ext = archive_write_disk_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_disk_set_options( ext, flags );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_disk_set_standard_lookup( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( (r = archive_read_open_filename( a, archiveName.toLocal8Bit().data(), 10240 ) ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "Unable to read archive:" << archive_error_string( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( true ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_read_next_header( a, &entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r == ARCHIVE_EOF ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "EOF";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( a ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( a ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_write_header( ext, entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( archive_entry_size( entry ) == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = copyData( a, ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_write_finish_entry( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_close( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_free( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_close( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_free( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.lz4" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* LZ4 Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest.chop( 4 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int i = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( exists( dest ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- i++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest.chop( 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = dirName( dest ) + QString( "(%1) - " ).arg( i ) + baseName( dest );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unlz4( archiveName.toLocal8Bit().constData(), dest.toLocal8Bit().constData(), NULL );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.gz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* GZip Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest.chop( 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int i = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( exists( dest ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- i++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest.chop( 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = dirName( dest ) + QString( "(%1) - " ).arg( i ) + baseName( dest );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- NBGZip *gzExt = new NBGZip( archiveName, dest );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return gzExt->extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.bz2" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* BZip2 Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest.chop( 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int i = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( exists( dest ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- i++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest.chop( 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = dirName( dest ) + QString( "(%1) - " ).arg( i ) + baseName( dest );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- NBBZip2 *bz2Ext = new NBBZip2( archiveName, dest );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return bz2Ext->extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.lzma" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* LZMA Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest.chop( 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int i = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( exists( dest ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- i++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest.chop( 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = dirName( dest ) + QString( "(%1) - " ).arg( i ) + baseName( dest );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- NBLzma *lzmaExt = new NBLzma( archiveName, dest );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return lzmaExt->extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.xz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* XZ Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest.chop( 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int i = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( exists( dest ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- i++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest.chop( 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dest = dirName( dest ) + QString( "(%1) - " ).arg( i ) + baseName( dest );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- NBXz *xzExt = new NBXz( archiveName, dest );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return xzExt->extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * To show progress we want the number of entries. So list the archive first.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * Then count the number of members. Then clear the memberList
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- listArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int entryCount = memberList.length();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- memberList.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- readDone = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive *ext;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int flags;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int r = ARCHIVE_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int processedEntries = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Select which attributes we want to restore. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags = ARCHIVE_EXTRACT_TIME;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_PERM;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_ACL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_FFLAGS;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Source Archive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- a = archive_read_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r |= archive_read_support_format_all( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r |= archive_read_support_filter_all( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( (r |= archive_read_open_filename( a, archiveName.toUtf8().data(), 10240 ) ) < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( a ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = ARCHIVE_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Structure to write files to disk
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ext = archive_write_disk_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r |= archive_write_disk_set_options( ext, flags );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r |= archive_write_disk_set_standard_lookup( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( a ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( true ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_read_next_header( a, &entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r == ARCHIVE_EOF ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( a ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_write_header( ext, entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( archive_entry_size( entry ) > 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = copyData( a, ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- processedEntries++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- emit progress( processedEntries * 100 / entryCount );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qApp->processEvents();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_write_finish_entry( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_close( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_free( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_close( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_free( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- chdir( srcDir );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_FOREACH (QString loc, exeLocs)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (exists(loc + "/lzop"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ lzop = loc + "/lzop";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not lzop.count())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "External program lzop not found.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive *ext;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int flags;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int r = ARCHIVE_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Select which attributes we want to restore. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags = ARCHIVE_EXTRACT_TIME;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_PERM;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_ACL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_FFLAGS;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Source Archive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ a = archive_read_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r |= archive_read_support_format_raw(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r |= archive_read_support_filter_program(a, QString(lzop + " -d").toLocal8Bit().data());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "Cannot use the input filter/format.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Structure to write files to disk
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ext = archive_write_disk_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_disk_set_options(ext, flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_disk_set_standard_lookup(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((r = archive_read_open_filename(a, archiveName.toLocal8Bit().data(), 10240)))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "Unable to read archive:" << archive_error_string(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (true)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_read_next_header(a, &entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r == ARCHIVE_EOF)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "EOF";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(a));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(a));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_write_header(ext, entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (archive_entry_size(entry) == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = copyData(a, ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_write_finish_entry(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_close(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_free(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_close(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_free(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.lz4"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* LZ4 Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest.chop(4);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int i = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (exists(dest))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ i++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest.chop(3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = dirName(dest) + QString("(%1) - ").arg(i) + baseName(dest);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unlz4(archiveName.toLocal8Bit().constData(), dest.toLocal8Bit().constData(), NULL);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.gz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* GZip Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest.chop(3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int i = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (exists(dest))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ i++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest.chop(3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = dirName(dest) + QString("(%1) - ").arg(i) + baseName(dest);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NBGZip *gzExt = new NBGZip(archiveName, dest);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return gzExt->extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.bz2"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* BZip2 Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest.chop(3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int i = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (exists(dest))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ i++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest.chop(3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = dirName(dest) + QString("(%1) - ").arg(i) + baseName(dest);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NBBZip2 *bz2Ext = new NBBZip2(archiveName, dest);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return bz2Ext->extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.lzma"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* LZMA Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest.chop(3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int i = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (exists(dest))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ i++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest.chop(3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = dirName(dest) + QString("(%1) - ").arg(i) + baseName(dest);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NBLzma *lzmaExt = new NBLzma(archiveName, dest);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return lzmaExt->extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.xz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* XZ Extractor */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest.chop(3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int i = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (exists(dest))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ i++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest.chop(3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dest = dirName(dest) + QString("(%1) - ").arg(i) + baseName(dest);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NBXz *xzExt = new NBXz(archiveName, dest);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return xzExt->extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* To show progress we want the number of entries. So list the archive first. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Then count the number of members. Then clear the memberList */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ listArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int entryCount = memberList.count();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ memberList.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ readDone = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive *ext;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int flags;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int r = ARCHIVE_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int processedEntries = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Select which attributes we want to restore. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags = ARCHIVE_EXTRACT_TIME;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_PERM;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_ACL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_FFLAGS;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Source Archive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ a = archive_read_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r |= archive_read_support_format_all(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r |= archive_read_support_filter_all(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((r |= archive_read_open_filename(a, archiveName.toUtf8().data(), 10240)) < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(a));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = ARCHIVE_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Structure to write files to disk
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ext = archive_write_disk_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r |= archive_write_disk_set_options(ext, flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r |= archive_write_disk_set_standard_lookup(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(a));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (true)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_read_next_header(a, &entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r == ARCHIVE_EOF)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(a));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_write_header(ext, entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (archive_entry_size(entry) > 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = copyData(a, ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ processedEntries++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ emit progress(processedEntries * 100 / entryCount);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qApp->processEvents();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_write_finish_entry(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_close(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_free(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_close(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_free(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ chdir(srcDir);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-bool LibArchiveQt::doExtractMember( QString memberName ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- listArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( archiveType == Single ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return doExtractMember( memberName );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Change to the target directory
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- char srcDir[ 10240 ] = { 0 };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getcwd( srcDir, 10240 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- chdir( dest.toUtf8().data() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive *ext;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int flags;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int r;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Select which attributes we want to restore. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags = ARCHIVE_EXTRACT_TIME;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_PERM;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_ACL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- flags |= ARCHIVE_EXTRACT_FFLAGS;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Source Archive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- a = archive_read_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_support_format_all( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_support_filter_all( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Structure to write files to disk
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ext = archive_write_disk_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_disk_set_options( ext, flags );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_disk_set_standard_lookup( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_read_open_filename( a, archiveName.toUtf8().data(), 10240 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r != ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "[ERROR]: Failed to open archive:" << archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- bool dir = false, found = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Direct member */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_FOREACH (ArchiveEntry *ae, memberList) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( ae->name == memberName ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dir = (ae->type == AE_IFDIR);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- found = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( ae->name == memberName + "/" ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- memberName += "/";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dir = (ae->type == AE_IFDIR);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- found = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not found ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Always check for @memberName + "/" because, all indirect members will be directories */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- memberName += "/";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Indirect member: ex. debug/ is a member if debug/path/to/file.ext exists */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_FOREACH (ArchiveEntry *ae, memberList) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( ae->name.startsWith( memberName ) == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dir = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- found = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( found ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( true ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_read_next_header( a, &entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r == ARCHIVE_EOF ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( a ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString entryPath = archive_entry_pathname( entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Check if the current entry starts with @memberName */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( entryPath.startsWith( memberName ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not dir ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( entryPath != memberName ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- continue;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_write_header( ext, entry );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( archive_entry_size( entry ) > 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = copyData( a, ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_write_finish_entry( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( ext ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_WARN ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- qDebug() << "[Error]" << "File not found in the archive:" << memberName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_close( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_read_free( a );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_close( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archive_write_free( ext );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- chdir( srcDir );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool LibArchiveQt::doExtractMember(QString memberName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ listArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (archiveType == Single)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return doExtractMember(memberName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Change to the target directory
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char srcDir[10240] = { 0 };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ getcwd(srcDir, 10240);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ chdir(dest.toUtf8().data());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive *a;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive *ext;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct archive_entry *entry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int flags;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int r;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Select which attributes we want to restore. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags = ARCHIVE_EXTRACT_TIME;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_PERM;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_ACL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags |= ARCHIVE_EXTRACT_FFLAGS;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Source Archive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ a = archive_read_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_support_format_all(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_support_filter_all(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Structure to write files to disk
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ext = archive_write_disk_new();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_disk_set_options(ext, flags);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_disk_set_standard_lookup(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_read_open_filename(a, archiveName.toUtf8().data(), 10240);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r != ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "[ERROR]: Failed to open archive:" << archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool dir = false, found = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Direct member */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_FOREACH (ArchiveEntry *ae, memberList)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ae->name == memberName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dir = (ae->type == AE_IFDIR);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ found = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ae->name == memberName + "/")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ memberName += "/";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dir = (ae->type == AE_IFDIR);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ found = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not found)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Always check for @memberName + "/" because, all indirect members will be directories */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ memberName += "/";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Indirect member: ex. debug/ is a member if debug/path/to/file.ext exists */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_FOREACH (ArchiveEntry *ae, memberList)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ae->name.startsWith(memberName) == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dir = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ found = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (found)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (true)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_read_next_header(a, &entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r == ARCHIVE_EOF)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(a));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString entryPath = archive_entry_pathname(entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Check if the current entry starts with @memberName */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (entryPath.startsWith(memberName))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not dir)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (entryPath != memberName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ continue;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_write_header(ext, entry);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (archive_entry_size(entry) > 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = copyData(a, ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_write_finish_entry(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(ext));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_WARN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDebug() << "[Error]" << "File not found in the archive:" << memberName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_close(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_read_free(a);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_close(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archive_write_free(ext);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ chdir(srcDir);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-int LibArchiveQt::copyData( struct archive *ar, struct archive *aw ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int r;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- const void *buff;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- size_t size;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++int LibArchiveQt::copyData(struct archive *ar, struct archive *aw)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int r;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const void *buff;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ size_t size;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #ifdef __LP64__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- off_t offset;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ off_t offset;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- la_int64_t offset;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ la_int64_t offset;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( true ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_read_data_block( ar, &buff, &size, &offset );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r == ARCHIVE_EOF ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (ARCHIVE_OK);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (r);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- r = archive_write_data_block( aw, buff, size, offset );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( r < ARCHIVE_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf( stderr, "%s\n", archive_error_string( aw ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return (r);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (true)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_read_data_block(ar, &buff, &size, &offset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r == ARCHIVE_EOF)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(ARCHIVE_OK);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(r);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ r = archive_write_data_block(aw, buff, size, offset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (r < ARCHIVE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fprintf(stderr, "%s\n", archive_error_string(aw));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(r);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-void LibArchiveQt::setFilterFormat( QMimeType mType ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( mType == mimeDb.mimeTypeForFile( "file.cpio" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_CPIO;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.shar" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_SHAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.gz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_GZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.grz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_GRZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.xz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_XZ;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.lzo" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_LZOP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.lzma" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_LZMA;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.lz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_LZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.lrz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_LRZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void LibArchiveQt::setFilterFormat(QMimeType mType)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (mType == mimeDb.mimeTypeForFile("file.cpio"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_CPIO;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.shar"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_SHAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.gz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_GZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.grz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_GRZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.xz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_XZ;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.lzo"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_LZOP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.lzma"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_LZMA;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.lz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_LZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.lrz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_LRZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #if ARCHIVE_VERSION_NUMBER > 3001002
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.lz4" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_LZ4;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.lz4"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_LZ4;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.bz2" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_BZIP2;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.tar.Z" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_COMPRESS;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.iso" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_ISO9660;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.zip" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_ZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.ar" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_AR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.xar" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_XAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.7z" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_7ZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.lz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_LZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.bz2"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_BZIP2;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.tar.Z"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_COMPRESS;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_TAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.iso"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_ISO9660;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.zip"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_ZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.ar"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_AR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.xar"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_XAR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.7z"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_7ZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Container;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.lz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_LZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #if ARCHIVE_VERSION_NUMBER > 3001002
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.lz4" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_LZ4;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.lz4"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_LZ4;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.uu" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_UU;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.lzo" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_LZOP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.gz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_GZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.bz2" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_BZIP2;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.lzma" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_LZMA;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( mType == mimeDb.mimeTypeForFile( "file.xz" ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_XZ;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFormat = ARCHIVE_FORMAT_EMPTY;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- archiveType = None;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.uu"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_UU;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.lzo"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_LZOP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.gz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_GZIP;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.bz2"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_BZIP2;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.lzma"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_LZMA;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (mType == mimeDb.mimeTypeForFile("file.xz"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_XZ;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_RAW;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = Single;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFormat = ARCHIVE_FORMAT_EMPTY;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mArchiveFilter = ARCHIVE_FILTER_NONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ archiveType = None;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/LibBZip2.cpp lib/LibBZip2.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 49e4b60..206cfa1 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/LibBZip2.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/LibBZip2.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,19 +1,27 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-/**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * Copyright 2018 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- **/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Copyright 2018 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // Local Headers
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include <LibBZip2.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -23,69 +31,80 @@ const int MAX_READ_SIZE = 40960;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ QString NBBZip2::bz2FileName = QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ QString NBBZip2::fileName = QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-NBBZip2::NBBZip2( QString archive, QString file ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int error = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- bz2FileName = QString( archive );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not file.isEmpty() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( QFileInfo( file ).isDir() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = QDir( file ).filePath( QString( archive ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName.chop( 4 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( QFileInfo( file ).exists() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QFile::rename( file, file + ".old" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = QString( file );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = QString( file );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = QString( archive );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName.chop( 4 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- bzFile = fopen( qPrintable( bz2FileName ), "r" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- bz2 = BZ2_bzReadOpen( &error, bzFile, 0, 0, NULL, 0 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++NBBZip2::NBBZip2(QString archive, QString file)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int error = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bz2FileName = QString(archive);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not file.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (QFileInfo(file).isDir())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = QDir(file).filePath(QString(archive));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName.chop(4);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (QFileInfo(file).exists())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFile::rename(file, file + ".old");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = QString(file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = QString(file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = QString(archive);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName.chop(4);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bzFile = fopen(qPrintable(bz2FileName), "r");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bz2 = BZ2_bzReadOpen(&error, bzFile, 0, 0, NULL, 0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-bool NBBZip2::extract() {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int error;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool NBBZip2::extract()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int error;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Reading from the bz2 file opened
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- std::ofstream ofile( qPrintable( fileName ), std::ofstream::binary );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Reading from the bz2 file opened
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ std::ofstream ofile(qPrintable(fileName), std::ofstream::binary);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( true ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- char buffer[ MAX_READ_SIZE ] = { "\x00" };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int charsRead = BZ2_bzRead( &error, bz2, buffer, MAX_READ_SIZE );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ofile.write( buffer, charsRead );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (true)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char buffer[MAX_READ_SIZE] = { "\x00" };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int charsRead = BZ2_bzRead(&error, bz2, buffer, MAX_READ_SIZE);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ofile.write(buffer, charsRead);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( error == BZ_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- continue;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (error == BZ_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ continue;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( error != BZ_STREAM_END ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (error != BZ_STREAM_END)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Close the file
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- BZ2_bzReadClose( &error, bz2 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Close the file
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ BZ2_bzReadClose(&error, bz2);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( error != BZ_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (error != BZ_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fclose( bzFile );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fclose(bzFile);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/LibBZip2.hpp lib/LibBZip2.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 1403337..c3660a4 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/LibBZip2.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/LibBZip2.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,6 +1,8 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-/**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * LibBZip2.hpp - LibBZip2.cpp header
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- **/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * LibBZip2.hpp - LibBZip2.cpp header
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++*/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #pragma once
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -9,15 +11,16 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include <bzlib.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ class NBBZip2 {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- NBBZip2( QString, QString file = QString() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- bool extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- static QString fileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- static QString bz2FileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NBBZip2( QString, QString file = QString() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- BZFILE *bz2;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- FILE *bzFile;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int NBBZip2Error;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QString fileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QString bz2FileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ BZFILE *bz2;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ FILE *bzFile;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int NBBZip2Error;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/LibGZip.cpp lib/LibGZip.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index b2d5d82..b36f8b5 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/LibGZip.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/LibGZip.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,82 +1,100 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-/**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * Copyright 2018 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- **/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Copyright 2018 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // Local Headers
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#include "LibGZip.hpp"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <LibGZip.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ const int MAX_READ_SIZE = 40960;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ QString NBGZip::gzFileName = QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ QString NBGZip::fileName = QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-NBGZip::NBGZip( QString archive, QString file ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- gzFileName = QString( archive );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not file.isEmpty() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( QFileInfo( file ).isDir() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = QDir( file ).filePath( QString( archive ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName.chop( 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( QFileInfo( file ).exists() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QFile::rename( file, file + ".old" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = QString( file );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = QString( file );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- gzip = gzopen( qPrintable( gzFileName ), "rb" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++NBGZip::NBGZip(QString archive, QString file)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gzFileName = QString(archive);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not file.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (QFileInfo(file).isDir())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = QDir(file).filePath(QString(archive));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName.chop(3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (QFileInfo(file).exists())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFile::rename(file, file + ".old");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = QString(file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = QString(file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gzip = gzopen(qPrintable(gzFileName), "rb");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-bool NBGZip::extract() {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( gzip == NULL ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Reading from the bz2 file opened
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- std::ofstream ofile( qPrintable( fileName ), std::ofstream::binary );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( true ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- char buffer[ MAX_READ_SIZE ] = { "\x00" };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int charsRead = gzread( gzip, buffer, sizeof(buffer) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( charsRead > 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ofile.write( buffer, charsRead );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( charsRead == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Close the file
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ofile.close();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( gzclose( gzip ) != Z_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool NBGZip::extract()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (gzip == NULL)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Reading from the bz2 file opened
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ std::ofstream ofile(qPrintable(fileName), std::ofstream::binary);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (true)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char buffer[MAX_READ_SIZE] = { "\x00" };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int charsRead = gzread(gzip, buffer, sizeof(buffer));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (charsRead > 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ofile.write(buffer, charsRead);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (charsRead == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Close the file
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ofile.close();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (gzclose(gzip) != Z_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/LibGZip.hpp lib/LibGZip.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 3914b3b..dd836d1 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/LibGZip.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/LibGZip.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,6 +1,8 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-/**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * LibGZip.hpp - LibGZip.cpp header
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- **/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * LibGZip.hpp - LibGZip.cpp header
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++*/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #pragma once
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -9,14 +11,15 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include <zlib.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ class NBGZip {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- NBGZip( QString, QString file = QString() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- bool extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- static QString fileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- static QString gzFileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NBGZip( QString, QString file = QString() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- gzFile gzip;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int NBGZipError;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QString fileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QString gzFileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gzFile gzip;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int NBGZipError;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/LibLzma.cpp lib/LibLzma.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 55222c0..b0fafd2 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/LibLzma.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/LibLzma.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,19 +1,27 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-/**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * Copyright 2018 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- **/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Copyright 2018 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // Local Headers
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include <LibLzma.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -23,87 +31,101 @@ const int MAX_READ_SIZE = 40960;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ QString NBLzma::lzmaFileName = QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ QString NBLzma::fileName = QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-NBLzma::NBLzma( QString archive, QString file ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- lzmaFileName = QString( archive );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not file.isEmpty() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( QFileInfo( file ).isDir() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = QDir( file ).filePath( QString( archive ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName.chop( 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( QFileInfo( file ).exists() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QFile::rename( file, file + ".old" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = QString( file );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = QString( file );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fdin = fopen( qPrintable( lzmaFileName ), "rb" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fdout = fopen( qPrintable( fileName ), "wb" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++NBLzma::NBLzma(QString archive, QString file)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ lzmaFileName = QString(archive);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not file.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (QFileInfo(file).isDir())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = QDir(file).filePath(QString(archive));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName.chop(3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (QFileInfo(file).exists())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFile::rename(file, file + ".old");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = QString(file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = QString(file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fdin = fopen(qPrintable(lzmaFileName), "rb");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fdout = fopen(qPrintable(fileName), "wb");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-bool NBLzma::extract() {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- lzma_stream strm = LZMA_STREAM_INIT;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- lzma_ret ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Initialize the decoder
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ret = lzma_alone_decoder( &strm, UINT64_MAX );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( ret != LZMA_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- uint8_t in_buf[ MAX_READ_SIZE ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- uint8_t out_buf[ MAX_READ_SIZE ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.avail_in = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.next_out = out_buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.avail_out = MAX_READ_SIZE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- lzma_action action = LZMA_RUN;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( true ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( strm.avail_in == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.next_in = in_buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.avail_in = fread( in_buf, 1, MAX_READ_SIZE, fdin );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( ferror( fdin ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( feof( fdin ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- action = LZMA_FINISH;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ret = lzma_code( &strm, action );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( (strm.avail_out == 0) || (ret != LZMA_OK) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- const size_t write_size = MAX_READ_SIZE - strm.avail_out;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( fwrite( out_buf, 1, write_size, fdout ) != write_size ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.next_out = out_buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.avail_out = MAX_READ_SIZE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( ret != LZMA_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( ret == LZMA_STREAM_END ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // lzma_stream_decoder() already guarantees that there's no trailing garbage.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- assert( strm.avail_in == 0 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- assert( action == LZMA_FINISH );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- assert( feof( fdin ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool NBLzma::extract()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ lzma_stream strm = LZMA_STREAM_INIT;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ lzma_ret ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Initialize the decoder
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ret = lzma_alone_decoder(&strm, UINT64_MAX);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ret != LZMA_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ uint8_t in_buf[MAX_READ_SIZE];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ uint8_t out_buf[MAX_READ_SIZE];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.avail_in = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.next_out = out_buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.avail_out = MAX_READ_SIZE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ lzma_action action = LZMA_RUN;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (true)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (strm.avail_in == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.next_in = in_buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.avail_in = fread(in_buf, 1, MAX_READ_SIZE, fdin);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ferror(fdin))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (feof(fdin))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ action = LZMA_FINISH;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ret = lzma_code(&strm, action);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((strm.avail_out == 0) || (ret != LZMA_OK))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const size_t write_size = MAX_READ_SIZE - strm.avail_out;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (fwrite(out_buf, 1, write_size, fdout) != write_size)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.next_out = out_buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.avail_out = MAX_READ_SIZE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ret != LZMA_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ret == LZMA_STREAM_END)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // lzma_stream_decoder() already guarantees that there's no trailing garbage.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ assert(strm.avail_in == 0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ assert(action == LZMA_FINISH);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ assert(feof(fdin));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/LibLzma.hpp lib/LibLzma.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 3a4d347..02e4586 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/LibLzma.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/LibLzma.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,6 +1,8 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-/**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * LibLzma.hpp - LibLzma.cpp header
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- **/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * LibLzma.hpp - LibLzma.cpp header
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++*/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #pragma once
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -9,14 +11,15 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include <lzma.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ class NBLzma {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- NBLzma( QString, QString file = QString() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- bool extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- static QString fileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- static QString lzmaFileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NBLzma( QString, QString file = QString() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- FILE *fdin, *fdout;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int NBLzmaError;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QString fileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QString lzmaFileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ FILE *fdin, *fdout;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int NBLzmaError;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/LibLzma2.cpp lib/LibLzma2.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 109d2bf..7fb7d5e 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/LibLzma2.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/LibLzma2.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,19 +1,27 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-/**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * Copyright 2018 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- **/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Copyright 2018 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // Local Headers
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include <LibLzma2.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -23,92 +31,108 @@ const int MAX_READ_SIZE = 40960;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ QString NBXz::xzFileName = QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ QString NBXz::fileName = QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-NBXz::NBXz( QString archive, QString file ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- xzFileName = QString( archive );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( not file.isEmpty() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( QFileInfo( file ).isDir() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = QDir( file ).filePath( QString( archive ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName.chop( 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if ( QFileInfo( file ).exists() ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QFile::rename( file, file + ".old" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = QString( file );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = QString( file );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName = file;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fileName.chop( 3 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fdin = fopen( qPrintable( xzFileName ), "rb" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fdout = fopen( qPrintable( fileName ), "wb" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++NBXz::NBXz(QString archive, QString file)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ xzFileName = QString(archive);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (not file.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (QFileInfo(file).isDir())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = QDir(file).filePath(QString(archive));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName.chop(3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (QFileInfo(file).exists())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFile::rename(file, file + ".old");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = QString(file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = QString(file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName = file;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileName.chop(3);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fdin = fopen(qPrintable(xzFileName), "rb");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fdout = fopen(qPrintable(fileName), "wb");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-bool NBXz::extract() {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- lzma_stream strm = LZMA_STREAM_INIT;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- lzma_ret ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Initialize the decoder
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ret = lzma_stream_decoder( &strm, UINT64_MAX, LZMA_CONCATENATED );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( ret != LZMA_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- uint8_t in_buf[ MAX_READ_SIZE ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- uint8_t out_buf[ MAX_READ_SIZE ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.avail_in = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.next_out = out_buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.avail_out = MAX_READ_SIZE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- lzma_action action = LZMA_RUN;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( true ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( strm.avail_in == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.next_in = in_buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.avail_in = fread( in_buf, 1, MAX_READ_SIZE, fdin );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( ferror( fdin ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( feof( fdin ) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- action = LZMA_FINISH;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ret = lzma_code( &strm, action );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( (strm.avail_out == 0) || (ret != LZMA_OK) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- const size_t write_size = MAX_READ_SIZE - strm.avail_out;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( fwrite( out_buf, 1, write_size, fdout ) != write_size ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.next_out = out_buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strm.avail_out = MAX_READ_SIZE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( ret != LZMA_OK ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( ret == LZMA_STREAM_END ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // lzma_stream_decoder() already guarantees that there's no trailing garbage.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- assert( strm.avail_in == 0 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- assert( action == LZMA_FINISH );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- assert( feof( fdin ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool NBXz::extract()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ lzma_stream strm = LZMA_STREAM_INIT;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ lzma_ret ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Initialize the decoder
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ret = lzma_stream_decoder(&strm, UINT64_MAX, LZMA_CONCATENATED);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ret != LZMA_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ uint8_t in_buf[MAX_READ_SIZE];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ uint8_t out_buf[MAX_READ_SIZE];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.avail_in = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.next_out = out_buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.avail_out = MAX_READ_SIZE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ lzma_action action = LZMA_RUN;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (true)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (strm.avail_in == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.next_in = in_buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.avail_in = fread(in_buf, 1, MAX_READ_SIZE, fdin);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ferror(fdin))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (feof(fdin))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ action = LZMA_FINISH;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ret = lzma_code(&strm, action);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((strm.avail_out == 0) || (ret != LZMA_OK))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const size_t write_size = MAX_READ_SIZE - strm.avail_out;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (fwrite(out_buf, 1, write_size, fdout) != write_size)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.next_out = out_buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ strm.avail_out = MAX_READ_SIZE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ret != LZMA_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ret == LZMA_STREAM_END)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // lzma_stream_decoder() already guarantees that there's no trailing garbage.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ assert(strm.avail_in == 0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ assert(action == LZMA_FINISH);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ assert(feof(fdin));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/LibLzma2.hpp lib/LibLzma2.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 440c182..b9efb42 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/LibLzma2.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/LibLzma2.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,6 +1,8 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-/**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * LibLzma.hpp - LibLzma.cpp header
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- **/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * LibLzma.hpp - LibLzma.cpp header
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++*/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #pragma once
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -9,14 +11,15 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include <lzma.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ class NBXz {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- NBXz( QString, QString file = QString() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- bool extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- static QString fileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- static QString xzFileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NBXz( QString, QString file = QString() );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool extract();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- FILE *fdin, *fdout;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int NBXzError;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QString fileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QString xzFileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ FILE *fdin, *fdout;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int NBXzError;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeDatabase.cpp lib/MimeHandler/NBMimeDatabase.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..926c047
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeDatabase.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,704 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <qplatformdefs.h> // always first
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeDatabase.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeDatabase_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeProvider_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeType_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QFile>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QFileInfo>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QSet>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QBuffer>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QUrl>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QStack>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QDebug>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <algorithm>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <functional>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool qt_isQMimeDatabaseDebuggingActivated(false);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef QT_NO_DEBUG_OUTPUT
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define DBG() if (qt_isQMimeDatabaseDebuggingActivated) qDebug() << static_cast<const void *>(this) << Q_FUNC_INFO
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define DBG() if (0) qDebug() << static_cast<const void *>(this) << Q_FUNC_INFO
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++Q_GLOBAL_STATIC(QMimeDatabasePrivate, staticQMimeDatabase)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeDatabasePrivate *QMimeDatabasePrivate::instance()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return staticQMimeDatabase();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeDatabasePrivate::QMimeDatabasePrivate()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ : m_provider(0), m_defaultMimeType(QLatin1String("application/octet-stream"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeDatabasePrivate::~QMimeDatabasePrivate()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ delete m_provider;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_provider = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeProviderBase *QMimeDatabasePrivate::provider()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!m_provider)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeProviderBase *binaryProvider = new QMimeBinaryProvider(this);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (binaryProvider->isValid())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_provider = binaryProvider;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ delete binaryProvider;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_provider = new QMimeXMLProvider(this);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return m_provider;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeDatabasePrivate::setProvider(QMimeProviderBase *theProvider)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ delete m_provider;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_provider = theProvider;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \internal
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns a MIME type or an invalid one if none found
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeDatabasePrivate::mimeTypeForName(const QString& nameOrAlias)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return provider()->mimeTypeForName(provider()->resolveAlias(nameOrAlias));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QStringList QMimeDatabasePrivate::mimeTypeForFileName(const QString& fileName, QString *foundSuffix)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (fileName.endsWith(QLatin1Char('/')))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QStringList() << QLatin1String("inode/directory");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringList matchingMimeTypes = provider()->findByFileName(QFileInfo(fileName).fileName(), foundSuffix);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return matchingMimeTypes;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static inline bool isTextFile(const QByteArray& data)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // UTF16 byte order marks
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static const char bigEndianBOM[] = "\xFE\xFF";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static const char littleEndianBOM[] = "\xFF\xFE";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (data.startsWith(bigEndianBOM) || data.startsWith(littleEndianBOM))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Check the first 32 bytes (see shared-mime spec)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *p = data.constData();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *e = p + qMin(32, data.size());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for ( ; p < e; ++p)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (((unsigned char)(*p) < 32) && (*p != 9) && (*p != 10) && (*p != 13))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeDatabasePrivate::findByData(const QByteArray& data, int *accuracyPtr)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (data.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *accuracyPtr = 100;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForName(QLatin1String("application/x-zerosize"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *accuracyPtr = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType candidate = provider()->findByMagic(data, accuracyPtr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (candidate.isValid())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return candidate;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (isTextFile(data))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *accuracyPtr = 5;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForName(QLatin1String("text/plain"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForName(defaultMimeType());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeDatabasePrivate::mimeTypeForNameAndData(const QString& fileName, QIODevice *device, int *accuracyPtr)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // First, glob patterns are evaluated. If there is a match with max weight,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // this one is selected and we are done. Otherwise, the file contents are
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // evaluated and the match with the highest value (either a magic priority or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // a glob pattern weight) is selected. Matching starts from max level (most
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // specific) in both cases, even when there is already a suffix matching candidate.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *accuracyPtr = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Pass 1) Try to match on the file name
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList candidatesByName = mimeTypeForFileName(fileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (candidatesByName.count() == 1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *accuracyPtr = 100;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QMimeType mime = mimeTypeForName(candidatesByName.at(0));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (mime.isValid())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mime;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ candidatesByName.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Extension is unknown, or matches multiple mimetypes.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Pass 2) Match on content, if we can read the data
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (device->isOpen())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Read 16K in one go (QIODEVICE_BUFFERSIZE in qiodevice_p.h).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // This is much faster than seeking back and forth into QIODevice.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QByteArray data = device->peek(16384);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int magicAccuracy = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType candidateByData(findByData(data, &magicAccuracy));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Disambiguate conflicting extensions (if magic matching found something)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (candidateByData.isValid() && (magicAccuracy > 0))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // "for glob_match in glob_matches:"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // "if glob_match is subclass or equal to sniffed_type, use glob_match"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString sniffedMime = candidateByData.name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QString& m, candidatesByName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (inherits(m, sniffedMime))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // We have magic + pattern pointing to this, so it's a pretty good match
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *accuracyPtr = 100;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForName(m);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *accuracyPtr = magicAccuracy;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return candidateByData;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (candidatesByName.count() > 1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *accuracyPtr = 20;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ candidatesByName.sort(); // to make it deterministic
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QMimeType mime = mimeTypeForName(candidatesByName.at(0));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (mime.isValid())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mime;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForName(defaultMimeType());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QList<QMimeType> QMimeDatabasePrivate::allMimeTypes()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return provider()->allMimeTypes();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeDatabasePrivate::inherits(const QString& mime, const QString& parent)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString resolvedParent = provider()->resolveAlias(parent);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //Q_ASSERT(provider()->resolveAlias(mime) == mime);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStack<QString> toCheck;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ toCheck.push(mime);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (!toCheck.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString current = toCheck.pop();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (current == resolvedParent)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QString& par, provider()->parents(current))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ toCheck.push(par);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \class QMimeDatabase
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \brief The QMimeDatabase class maintains a database of MIME types.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \since 5.0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * The MIME type database is provided by the freedesktop.org shared-mime-info
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * project. If the MIME type database cannot be found on the system, as is the case
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * on most Windows and Mac OS X systems, Qt will use its own copy of it.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Applications which want to define custom MIME types need to install an
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * XML file into the locations searched for MIME definitions.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * These locations can be queried with
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \code
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/packages"),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * QStandardPaths::LocateDirectory);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \endcode
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * On a typical Unix system, this will be /usr/share/mime/packages/, but it is also
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * possible to extend the list of directories by setting the environment variable
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * XDG_DATA_DIRS. For instance adding /opt/myapp/share to XDG_DATA_DIRS will result
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * in /opt/myapp/share/mime/packages/ being searched for MIME definitions.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Here is an example of MIME XML:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \code
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * <?xml version="1.0" encoding="UTF-8"?>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * <mime-type type="application/vnd.nokia.qt.qmakeprofile">
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * <comment xml:lang="en">Qt qmake Profile</comment>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * <glob pattern="*.pro" weight="50"/>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * </mime-type>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * </mime-info>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \endcode
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * For more details about the syntax of XML MIME definitions, including defining
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * "magic" in order to detect MIME types based on data as well, read the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Shared Mime Info specification at
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * On Unix systems, a binary cache is used for more performance. This cache is generated
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * by the command "update-mime-database path", where path would be /opt/myapp/share/mime
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * in the above example. Make sure to run this command when installing the MIME type
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * definition file.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \threadsafe
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \snippet doc/src/snippets/code/src_corelib_mimetype_qmimedatabase.cpp 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \sa QMimeType
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QMimeDatabase::QMimeDatabase();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Constructs this QMimeDatabase object.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeDatabase::QMimeDatabase() :
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d(staticQMimeDatabase())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QMimeDatabase::~QMimeDatabase();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Destroys the QMimeDatabase object.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeDatabase::~QMimeDatabase()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QMimeType QMimeDatabase::mimeTypeForName(const QString &nameOrAlias) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns a MIME type for \a nameOrAlias or an invalid one if none found.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeDatabase::mimeTypeForName(const QString& nameOrAlias) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMutexLocker locker(&d->mutex);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForName(nameOrAlias);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns a MIME type for \a fileInfo.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * A valid MIME type is always returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * The default matching algorithm looks at both the file name and the file
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * contents, if necessary. The file extension has priority over the contents,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * but the contents will be used if the file extension is unknown, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * matches multiple MIME types.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * If \a fileInfo is a Unix symbolic link, the file that it refers to
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * will be used instead.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * If the file doesn't match any known pattern or data, the default MIME type
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * (application/octet-stream) is returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * When \a mode is set to MatchExtension, only the file name is used, not
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * the file contents. The file doesn't even have to exist. If the file name
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * doesn't match any known pattern, the default MIME type (application/octet-stream)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * is returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * If multiple MIME types match this file, the first one (alphabetically) is returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * When \a mode is set to MatchContent, and the file is readable, only the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * file contents are used to determine the MIME type. This is equivalent to
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * calling mimeTypeForData with a QFile as input device.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * In all cases, the \a fileName can also include an absolute or relative path.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \sa isDefault, mimeTypeForData
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeDatabase::mimeTypeForFile(const QFileInfo& fileInfo, MatchMode mode) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "fileInfo" << fileInfo.absoluteFilePath();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMutexLocker locker(&d->mutex);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (fileInfo.isDir())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForName(QLatin1String("inode/directory"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFile file(fileInfo.absoluteFilePath());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef Q_OS_UNIX
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Cannot access statBuf.st_mode from the filesystem engine, so we have to stat again.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QByteArray nativeFilePath = QFile::encodeName(file.fileName());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QT_STATBUF statBuffer;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (QT_LSTAT(nativeFilePath.constData(), &statBuffer) == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (S_ISCHR(statBuffer.st_mode))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForName(QLatin1String("inode/chardevice"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (S_ISBLK(statBuffer.st_mode))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForName(QLatin1String("inode/blockdevice"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (S_ISFIFO(statBuffer.st_mode))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForName(QLatin1String("inode/fifo"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (S_ISSOCK(statBuffer.st_mode))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForName(QLatin1String("inode/socket"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int priority = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ switch (mode)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case MatchDefault:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ file.open(QIODevice::ReadOnly); // isOpen() will be tested by method below
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForNameAndData(fileInfo.absoluteFilePath(), &file, &priority);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case MatchExtension:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ locker.unlock();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForFile(fileInfo.absoluteFilePath(), mode);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case MatchContent:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (file.open(QIODevice::ReadOnly))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ locker.unlock();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForData(&file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForName(d->defaultMimeType());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ default:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_ASSERT(false);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForName(d->defaultMimeType());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns a MIME type for the file named \a fileName using \a mode.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \overload
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeDatabase::mimeTypeForFile(const QString& fileName, MatchMode mode) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (mode == MatchExtension)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMutexLocker locker(&d->mutex);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList matches = d->mimeTypeForFileName(fileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int matchCount = matches.count();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (matchCount == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForName(d->defaultMimeType());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (matchCount == 1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForName(matches.first());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // We have to pick one.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ matches.sort(); // Make it deterministic
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForName(matches.first());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Implemented as a wrapper around mimeTypeForFile(QFileInfo), so no mutex.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFileInfo fileInfo(fileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForFile(fileInfo);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns the MIME types for the file name \a fileName.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * If the file name doesn't match any known pattern, an empty list is returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * If multiple MIME types match this file, they are all returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This function does not try to open the file. To also use the content
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * when determining the MIME type, use mimeTypeForFile() or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * mimeTypeForNameAndData() instead.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \sa mimeTypeForFile
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QList<QMimeType> QMimeDatabase::mimeTypesForFileName(const QString& fileName) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMutexLocker locker(&d->mutex);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList matches = d->mimeTypeForFileName(fileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QList<QMimeType> mimes;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ matches.sort(); // Make it deterministic
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QString& mime, matches)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mimes.append(d->mimeTypeForName(mime));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimes;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns the suffix for the file \a fileName, as known by the MIME database.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This allows to pre-select "tar.bz2" for foo.tar.bz2, but still only
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * "txt" for my.file.with.dots.txt.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QMimeDatabase::suffixForFileName(const QString& fileName) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMutexLocker locker(&d->mutex);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString foundSuffix;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->mimeTypeForFileName(fileName, &foundSuffix);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return foundSuffix;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns a MIME type for \a data.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * A valid MIME type is always returned. If \a data doesn't match any
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * known MIME type data, the default MIME type (application/octet-stream)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * is returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeDatabase::mimeTypeForData(const QByteArray& data) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMutexLocker locker(&d->mutex);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int accuracy = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->findByData(data, &accuracy);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns a MIME type for the data in \a device.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * A valid MIME type is always returned. If the data in \a device doesn't match any
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * known MIME type data, the default MIME type (application/octet-stream)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * is returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeDatabase::mimeTypeForData(QIODevice *device) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMutexLocker locker(&d->mutex);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int accuracy = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const bool openedByUs = !device->isOpen() && device->open(QIODevice::ReadOnly);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (device->isOpen())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Read 16K in one go (QIODEVICE_BUFFERSIZE in qiodevice_p.h).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // This is much faster than seeking back and forth into QIODevice.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QByteArray data = device->peek(16384);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QMimeType result = d->findByData(data, &accuracy);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (openedByUs)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ device->close();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForName(d->defaultMimeType());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns a MIME type for \a url.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * If the URL is a local file, this calls mimeTypeForFile.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Otherwise the matching is done based on the file name only,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * except for schemes where file names don't mean much, like HTTP.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This method always returns the default mimetype for HTTP URLs,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * use QNetworkAccessManager to handle HTTP URLs properly.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * A valid MIME type is always returned. If \a url doesn't match any
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * known MIME type data, the default MIME type (application/octet-stream)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * is returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeDatabase::mimeTypeForUrl(const QUrl& url) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (url.scheme().compare("file", Qt::CaseInsensitive) == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForFile(url.toLocalFile());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString scheme = url.scheme();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (scheme.startsWith(QLatin1String("http")))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForName(d->defaultMimeType());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForFile(url.path());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns a MIME type for the given \a fileName and \a device data.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This overload can be useful when the file is remote, and we started to
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * download some of its data in a device. This allows to do full MIME type
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * matching for remote files as well.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * If the device is not open, it will be opened by this function, and closed
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * after the MIME type detection is completed.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * A valid MIME type is always returned. If \a device data doesn't match any
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * known MIME type data, the default MIME type (application/octet-stream)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * is returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This method looks at both the file name and the file contents,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * if necessary. The file extension has priority over the contents,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * but the contents will be used if the file extension is unknown, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * matches multiple MIME types.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeDatabase::mimeTypeForNameAndData(const QString& fileName, QIODevice *device) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "fileName" << fileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int accuracy = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const bool openedByUs = !device->isOpen() && device->open(QIODevice::ReadOnly);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QMimeType result = d->mimeTypeForNameAndData(fileName, device, &accuracy);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (openedByUs)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ device->close();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns a MIME type for the given \a fileName and device \a data.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This overload can be useful when the file is remote, and we started to
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * download some of its data. This allows to do full MIME type matching for
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * remote files as well.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * A valid MIME type is always returned. If \a data doesn't match any
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * known MIME type data, the default MIME type (application/octet-stream)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * is returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This method looks at both the file name and the file contents,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * if necessary. The file extension has priority over the contents,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * but the contents will be used if the file extension is unknown, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * matches multiple MIME types.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeDatabase::mimeTypeForNameAndData(const QString& fileName, const QByteArray& data) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "fileName" << fileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QBuffer buffer(const_cast<QByteArray *>(&data));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ buffer.open(QIODevice::ReadOnly);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int accuracy = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->mimeTypeForNameAndData(fileName, &buffer, &accuracy);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns the list of all available MIME types.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This can be useful for showing all MIME types to the user, for instance
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * in a MIME type editor. Do not use unless really necessary in other cases
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * though, prefer using the mimeTypeFor* methods for performance reasons.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QList<QMimeType> QMimeDatabase::allMimeTypes() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMutexLocker locker(&d->mutex);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->allMimeTypes();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#undef DBG
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeDatabase.hpp lib/MimeHandler/NBMimeDatabase.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..4eee5cd
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeDatabase.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,91 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef QMIMEDATABASE_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QMIMEDATABASE_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeType.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QtCore/QStringList>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QByteArray;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QFileInfo;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QIODevice;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QUrl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeDatabasePrivate;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeDatabase
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_DISABLE_COPY(QMimeDatabase)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeDatabase();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ~QMimeDatabase();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType mimeTypeForName(const QString &nameOrAlias) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ enum MatchMode {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ MatchDefault = 0x0,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ MatchExtension = 0x1,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ MatchContent = 0x2
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType mimeTypeForFile(const QString &fileName, MatchMode mode = MatchDefault) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode = MatchDefault) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QList<QMimeType> mimeTypesForFileName(const QString &fileName) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType mimeTypeForData(const QByteArray &data) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType mimeTypeForData(QIODevice *device) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType mimeTypeForUrl(const QUrl &url) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType mimeTypeForNameAndData(const QString &fileName, QIODevice *device) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType mimeTypeForNameAndData(const QString &fileName, const QByteArray &data) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString suffixForFileName(const QString &fileName) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QList<QMimeType> allMimeTypes() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeDatabasePrivate *d;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // QMIMEDATABASE_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeDatabase_p.hpp lib/MimeHandler/NBMimeDatabase_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..88d57ff
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeDatabase_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,87 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef QMIMEDATABASE_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QMIMEDATABASE_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QHash>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QMutex>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeType.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeType_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeGlobPattern_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeDatabase;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeProviderBase;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeDatabasePrivate
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_DISABLE_COPY(QMimeDatabasePrivate)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeDatabasePrivate();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ~QMimeDatabasePrivate();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QMimeDatabasePrivate *instance();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeProviderBase *provider();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void setProvider(QMimeProviderBase *theProvider);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline QString defaultMimeType() const { return m_defaultMimeType; }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool inherits(const QString &mime, const QString &parent);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QList<QMimeType> allMimeTypes();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType mimeTypeForName(const QString &nameOrAlias);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType mimeTypeForNameAndData(const QString &fileName, QIODevice *device, int *priorityPtr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType findByData(const QByteArray &data, int *priorityPtr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList mimeTypeForFileName(const QString &fileName, QString *foundSuffix = 0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mutable QMimeProviderBase *m_provider;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString m_defaultMimeType;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMutex mutex;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // QMIMEDATABASE_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeGlobPattern.cpp lib/MimeHandler/NBMimeGlobPattern.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..11f091c
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeGlobPattern.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,290 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeGlobPattern_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QRegExp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QStringList>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QDebug>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \internal
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \class QMimeGlobMatchResult
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \brief The QMimeGlobMatchResult class accumulates results from glob matching.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Handles glob weights, and preferring longer matches over shorter matches.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeGlobMatchResult::addMatch(const QString& mimeType, int weight, const QString& pattern)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Is this a lower-weight pattern than the last match? Skip this match then.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (weight < m_weight)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool replace = weight > m_weight;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!replace)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Compare the length of the match
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (pattern.length() < m_matchingPatternLength)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return; // too short, ignore
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (pattern.length() > m_matchingPatternLength)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // longer: clear any previous match (like *.bz2, when pattern is *.tar.bz2)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ replace = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (replace)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_matchingMimeTypes.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // remember the new "longer" length
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_matchingPatternLength = pattern.length();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_weight = weight;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_matchingMimeTypes.append(mimeType);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (pattern.startsWith(QLatin1String("*.")))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_foundSuffix = pattern.mid(2);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \internal
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \class QMimeGlobPattern
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \brief The QMimeGlobPattern class contains the glob pattern for file names for MIME type matching.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \sa QMimeType, QMimeDatabase, QMimeMagicRuleMatcher, QMimeMagicRule
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeGlobPattern::matchFileName(const QString& inputFilename) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // "Applications MUST match globs case-insensitively, except when the case-sensitive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // attribute is set to true."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // The constructor takes care of putting case-insensitive patterns in lowercase.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString filename = m_caseSensitivity == Qt::CaseInsensitive ? inputFilename.toLower() : inputFilename;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int pattern_len = m_pattern.length();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!pattern_len)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int len = filename.length();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int starCount = m_pattern.count(QLatin1Char('*'));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Patterns like "*~", "*.extension"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((m_pattern[0] == QLatin1Char('*')) && (m_pattern.indexOf(QLatin1Char('[')) == -1) && (starCount == 1))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (len + 1 < pattern_len)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QChar *c1 = m_pattern.unicode() + pattern_len - 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QChar *c2 = filename.unicode() + len - 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int cnt = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (cnt < pattern_len && *c1-- == *c2--)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ++cnt;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return cnt == pattern_len;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Patterns like "README*" (well this is currently the only one like that...)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((starCount == 1) && (m_pattern.at(pattern_len - 1) == QLatin1Char('*')))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (len + 1 < pattern_len)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (m_pattern.at(0) == QLatin1Char('*'))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return filename.indexOf(m_pattern.mid(1, pattern_len - 2)) != -1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QChar *c1 = m_pattern.unicode();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QChar *c2 = filename.unicode();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int cnt = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (cnt < pattern_len && *c1++ == *c2++)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ++cnt;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return cnt == pattern_len;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Names without any wildcards like "README"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((m_pattern.indexOf(QLatin1Char('[')) == -1) && (starCount == 0) && m_pattern.indexOf(QLatin1Char('?')))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return(m_pattern == filename);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Other (quite rare) patterns, like "*.anim[1-9j]": use slow but correct method
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QRegExp rx(m_pattern, Qt::CaseSensitive, QRegExp::WildcardUnix);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return rx.exactMatch(filename);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static bool isFastPattern(const QString& pattern)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // starts with "*.", has no other '*' and no other '.'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return pattern.lastIndexOf(QLatin1Char('*')) == 0 &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ pattern.lastIndexOf(QLatin1Char('.')) == 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // and contains no other special character
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ && !pattern.contains(QLatin1Char('?')) &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ !pattern.contains(QLatin1Char('['))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeAllGlobPatterns::addGlob(const QMimeGlobPattern& glob)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString& pattern = glob.pattern();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_ASSERT(!pattern.isEmpty());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Store each patterns into either m_fastPatternDict (*.txt, *.html etc. with default weight 50)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // or for the rest, like core.*, *.tar.bz2, *~, into highWeightPatternOffset (>50)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // or lowWeightPatternOffset (<=50)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((glob.weight() == 50) && isFastPattern(pattern) && !glob.isCaseSensitive())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // The bulk of the patterns is *.foo with weight 50 --> those go into the fast patterns hash.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString extension = pattern.mid(2).toLower();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList& patterns = m_fastPatterns[extension]; // find or create
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // This would just slow things down: if (!patterns.contains(glob.mimeType()))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ patterns.append(glob.mimeType());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (glob.weight() > 50)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // This would just slow things down: if (!m_highWeightGlobs.hasPattern(glob.mimeType(), glob.pattern()))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_highWeightGlobs.append(glob);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //This would just slow things down: if (!m_lowWeightGlobs.hasPattern(glob.mimeType(), glob.pattern()))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_lowWeightGlobs.append(glob);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeAllGlobPatterns::removeMimeType(const QString& mimeType)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMutableHashIterator<QString, QStringList> it(m_fastPatterns);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (it.hasNext())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ it.next().value().removeAll(mimeType);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_highWeightGlobs.removeMimeType(mimeType);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_lowWeightGlobs.removeMimeType(mimeType);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeGlobPatternList::match(QMimeGlobMatchResult& result,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString& fileName) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeGlobPatternList::const_iterator it = this->constBegin();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QMimeGlobPatternList::const_iterator endIt = this->constEnd();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for ( ; it != endIt; ++it)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QMimeGlobPattern& glob = *it;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (glob.matchFileName(fileName))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ result.addMatch(glob.mimeType(), glob.weight(), glob.pattern());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QStringList QMimeAllGlobPatterns::matchingGlobs(const QString& fileName, QString *foundSuffix) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // First try the high weight matches (>50), if any.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeGlobMatchResult result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_highWeightGlobs.match(result, fileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (result.m_matchingMimeTypes.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Now use the "fast patterns" dict, for simple *.foo patterns with weight 50
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // (which is most of them, so this optimization is definitely worth it)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int lastDot = fileName.lastIndexOf(QLatin1Char('.'));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (lastDot != -1) // if no '.', skip the extension lookup
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int ext_len = fileName.length() - lastDot - 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString simpleExtension = fileName.right(ext_len).toLower();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // (toLower because fast patterns are always case-insensitive and saved as lowercase)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringList matchingMimeTypes = m_fastPatterns.value(simpleExtension);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QString& mime, matchingMimeTypes)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ result.addMatch(mime, 50, QLatin1String("*.") + simpleExtension);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Can't return yet; *.tar.bz2 has to win over *.bz2, so we need the low-weight mimetypes anyway,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // at least those with weight 50.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Finally, try the low weight matches (<=50)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_lowWeightGlobs.match(result, fileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (foundSuffix)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *foundSuffix = result.m_foundSuffix;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return result.m_matchingMimeTypes;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeAllGlobPatterns::clear()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_fastPatterns.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_highWeightGlobs.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_lowWeightGlobs.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeGlobPattern_p.hpp lib/MimeHandler/NBMimeGlobPattern_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..c280b4f
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeGlobPattern_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,145 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef QMIMEGLOBPATTERN_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QMIMEGLOBPATTERN_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QStringList>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QHash>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++struct QMimeGlobMatchResult
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeGlobMatchResult()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ : m_weight(0), m_matchingPatternLength(0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void addMatch(const QString &mimeType, int weight, const QString &pattern);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList m_matchingMimeTypes;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int m_weight;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int m_matchingPatternLength;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString m_foundSuffix;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeGlobPattern
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static const unsigned MaxWeight = 100;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static const unsigned DefaultWeight = 50;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static const unsigned MinWeight = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ explicit QMimeGlobPattern(const QString &thePattern, const QString &theMimeType, unsigned theWeight = DefaultWeight, Qt::CaseSensitivity s = Qt::CaseInsensitive) :
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_pattern(thePattern), m_mimeType(theMimeType), m_weight(theWeight), m_caseSensitivity(s)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (s == Qt::CaseInsensitive) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_pattern = m_pattern.toLower();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ~QMimeGlobPattern() {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool matchFileName(const QString &filename) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline const QString &pattern() const { return m_pattern; }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline unsigned weight() const { return m_weight; }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline const QString &mimeType() const { return m_mimeType; }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline bool isCaseSensitive() const { return m_caseSensitivity == Qt::CaseSensitive; }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString m_pattern;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString m_mimeType;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int m_weight;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Qt::CaseSensitivity m_caseSensitivity;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeGlobPatternList : public QList<QMimeGlobPattern>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool hasPattern(const QString &mimeType, const QString &pattern) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const_iterator it = begin();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const const_iterator myend = end();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (; it != myend; ++it)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((*it).pattern() == pattern && (*it).mimeType() == mimeType)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "noglobs" is very rare occurrence, so it's ok if it's slow
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void removeMimeType(const QString &mimeType)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMutableListIterator<QMimeGlobPattern> it(*this);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (it.hasNext()) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (it.next().mimeType() == mimeType)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ it.remove();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void match(QMimeGlobMatchResult &result, const QString &fileName) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ \internal
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Result of the globs parsing, as data structures ready for efficient MIME type matching.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ This contains:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 1) a map of fast regular patterns (e.g. *.txt is stored as "txt" in a qhash's key)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 2) a linear list of high-weight globs
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 3) a linear list of low-weight globs
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeAllGlobPatterns
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ typedef QHash<QString, QStringList> PatternsMap; // MIME type -> patterns
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void addGlob(const QMimeGlobPattern &glob);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void removeMimeType(const QString &mimeType);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList matchingGlobs(const QString &fileName, QString *foundSuffix) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PatternsMap m_fastPatterns; // example: "doc" -> "application/msword", "text/plain"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeGlobPatternList m_highWeightGlobs;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeGlobPatternList m_lowWeightGlobs; // <= 50, including the non-fast 50 patterns
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // QMIMEGLOBPATTERN_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeMagicRule.cpp lib/MimeHandler/NBMimeMagicRule.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..0132b96
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeMagicRule.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,479 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QT_NO_CAST_FROM_ASCII
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeMagicRule_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QList>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QDebug>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QtEndian>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// in the same order as Type!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char magicRuleTypes_string[] =
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "invalid\0"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "string\0"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "host16\0"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "host32\0"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "big16\0"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "big32\0"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "little16\0"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "little32\0"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "byte\0"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "\0";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const int magicRuleTypes_indices[] = {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 0, 8, 15, 22, 29, 35, 41, 50, 59, 65, 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeMagicRule::Type QMimeMagicRule::type(const QByteArray& theTypeName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (int i = String; i <= Byte; ++i)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (theTypeName == magicRuleTypes_string + magicRuleTypes_indices[i])
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return Type(i);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return Invalid;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QByteArray QMimeMagicRule::typeName(QMimeMagicRule::Type theType)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return magicRuleTypes_string + magicRuleTypes_indices[theType];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeMagicRulePrivate
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool operator==(const QMimeMagicRulePrivate& other) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeMagicRule::Type type;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QByteArray value;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int startPos;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int endPos;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QByteArray mask;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QByteArray pattern;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ quint32 number;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ quint32 numberMask;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ typedef bool (*MatchFunction)(const QMimeMagicRulePrivate *d, const QByteArray& data);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ MatchFunction matchFunction;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeMagicRulePrivate::operator==(const QMimeMagicRulePrivate& other) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return type == other.type &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ value == other.value &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ startPos == other.startPos &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ endPos == other.endPos &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mask == other.mask &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ pattern == other.pattern &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ number == other.number &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ numberMask == other.numberMask &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ matchFunction == other.matchFunction;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// Used by both providers
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeMagicRule::matchSubstring(const char *dataPtr, int dataSize, int rangeStart, int rangeLength,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int valueLength, const char *valueData, const char *mask)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Size of searched data.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Example: value="ABC", rangeLength=3 -> we need 3+3-1=5 bytes (ABCxx,xABCx,xxABC would match)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int dataNeeded = qMin(rangeLength + valueLength - 1, dataSize - rangeStart);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!mask)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // callgrind says QByteArray::indexOf is much slower, since our strings are typically too
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // short for be worth Boyer-Moore matching (1 to 71 bytes, 11 bytes on average).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool found = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (int i = rangeStart; i < rangeStart + rangeLength; ++i)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (i + valueLength > dataSize)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (memcmp(valueData, dataPtr + i, valueLength) == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ found = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!found)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool found = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *readDataBase = dataPtr + rangeStart;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Example (continued from above):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // deviceSize is 4, so dataNeeded was max'ed to 4.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // maxStartPos = 4 - 3 + 1 = 2, and indeed
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // we need to check for a match a positions 0 and 1 (ABCx and xABC).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int maxStartPos = dataNeeded - valueLength + 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (int i = 0; i < maxStartPos; ++i)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *d = readDataBase + i;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool valid = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (int idx = 0; idx < valueLength; ++idx)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (((*d++) & mask[idx]) != (valueData[idx] & mask[idx]))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ valid = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (valid)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ found = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!found)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << "Found" << value << "in" << searchedData;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static bool matchString(const QMimeMagicRulePrivate *d, const QByteArray& data)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int rangeLength = d->endPos - d->startPos + 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QMimeMagicRule::matchSubstring(data.constData(), data.size(), d->startPos, rangeLength, d->pattern.size(), d->pattern.constData(), d->mask.constData());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++template<typename T>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static bool matchNumber(const QMimeMagicRulePrivate *d, const QByteArray& data)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const T value(d->number);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const T mask(d->numberMask);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << "matchNumber" << "0x" << QString::number(d->number, 16) << "size" << sizeof(T);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << "mask" << QString::number(d->numberMask, 16);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *p = data.constData() + d->startPos;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *e = data.constData() + qMin(data.size() - int(sizeof(T)), d->endPos + 1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for ( ; p <= e; ++p)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((*reinterpret_cast<const T *>(p) & mask) == (value & mask))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static inline QByteArray makePattern(const QByteArray& value)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QByteArray pattern(value.size(), Qt::Uninitialized);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char *data = pattern.data();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *p = value.constData();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *e = p + value.size();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for ( ; p < e; ++p)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((*p == '\\') && (++p < e))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (*p == 'x') // hex (\\xff)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char c = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (int i = 0; i < 2 && p + 1 < e; ++i)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ++p;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((*p >= '0') && (*p <= '9'))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ c = (c << 4) + *p - '0';
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if ((*p >= 'a') && (*p <= 'f'))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ c = (c << 4) + *p - 'a' + 10;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if ((*p >= 'A') && (*p <= 'F'))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ c = (c << 4) + *p - 'A' + 10;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ continue;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *data++ = c;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if ((*p >= '0') && (*p <= '7')) // oct (\\7, or \\77, or \\377)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char c = *p - '0';
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((p + 1 < e) && (p[1] >= '0') && (p[1] <= '7'))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ c = (c << 3) + *(++p) - '0';
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((p + 1 < e) && (p[1] >= '0') && (p[1] <= '7') && (p[-1] <= '3'))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ c = (c << 3) + *(++p) - '0';
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *data++ = c;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (*p == 'n')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *data++ = '\n';
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (*p == 'r')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *data++ = '\r';
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else // escaped
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *data++ = *p;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *data++ = *p;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ pattern.truncate(data - pattern.data());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return pattern;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeMagicRule::QMimeMagicRule(QMimeMagicRule::Type theType,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QByteArray& theValue,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int theStartPos,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int theEndPos,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QByteArray& theMask) :
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d(new QMimeMagicRulePrivate)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_ASSERT(!theValue.isEmpty());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->type = theType;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->value = theValue;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->startPos = theStartPos;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->endPos = theEndPos;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->mask = theMask;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->matchFunction = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((d->type >= Host16) && (d->type <= Byte))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool ok;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->number = d->value.toUInt(&ok, 0); // autodetect
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_ASSERT(ok);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->numberMask = !d->mask.isEmpty() ? d->mask.toUInt(&ok, 0) : 0; // autodetect
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ switch (d->type)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case String:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->pattern = makePattern(d->value);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->pattern.squeeze();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!d->mask.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_ASSERT(d->mask.size() >= 4 && d->mask.startsWith("0x"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->mask = QByteArray::fromHex(QByteArray::fromRawData(d->mask.constData() + 2, d->mask.size() - 2));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_ASSERT(d->mask.size() == d->pattern.size());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->mask.fill(char(-1), d->pattern.size());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->mask.squeeze();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->matchFunction = matchString;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case Byte:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (d->number <= quint8(-1))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (d->numberMask == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->numberMask = quint8(-1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->matchFunction = matchNumber<quint8>;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case Big16:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case Host16:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case Little16:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (d->number <= quint16(-1))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->number = d->type == Little16 ? qFromLittleEndian<quint16>(d->number) : qFromBigEndian<quint16>(d->number);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (d->numberMask == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->numberMask = quint16(-1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->matchFunction = matchNumber<quint16>;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case Big32:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case Host32:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case Little32:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (d->number <= quint32(-1))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->number = d->type == Little32 ? qFromLittleEndian<quint32>(d->number) : qFromBigEndian<quint32>(d->number);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (d->numberMask == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->numberMask = quint32(-1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->matchFunction = matchNumber<quint32>;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ default:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeMagicRule::QMimeMagicRule(const QMimeMagicRule& other) :
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d(new QMimeMagicRulePrivate(*other.d))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeMagicRule::~QMimeMagicRule()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeMagicRule& QMimeMagicRule::operator=(const QMimeMagicRule& other)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *d = *other.d;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return *this;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeMagicRule::operator==(const QMimeMagicRule& other) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d == other.d ||
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *d == *other.d;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeMagicRule::Type QMimeMagicRule::type() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->type;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QByteArray QMimeMagicRule::value() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->value;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++int QMimeMagicRule::startPos() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->startPos;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++int QMimeMagicRule::endPos() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->endPos;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QByteArray QMimeMagicRule::mask() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QByteArray result = d->mask;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (d->type == String)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // restore '0x'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ result = "0x" + result.toHex();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeMagicRule::isValid() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->matchFunction;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeMagicRule::matches(const QByteArray& data) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const bool ok = d->matchFunction && d->matchFunction(d.data(), data);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!ok)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // No submatch? Then we are done.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (m_subMatches.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << "Checking" << m_subMatches.count() << "sub-rules";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Check that one of the submatches matches too
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (QList<QMimeMagicRule>::const_iterator it = m_subMatches.begin(), end = m_subMatches.end();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ it != end; ++it)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((*it).matches(data))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // One of the hierarchies matched -> mimetype recognized.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeMagicRuleMatcher.cpp lib/MimeHandler/NBMimeMagicRuleMatcher.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..431cda8
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeMagicRuleMatcher.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,114 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QT_NO_CAST_FROM_ASCII
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeMagicRuleMatcher_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeType_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \internal
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \class QMimeMagicRuleMatcher
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \brief The QMimeMagicRuleMatcher class checks a number of rules based on operator "or".
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * It is used for rules parsed from XML files.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \sa QMimeType, QMimeDatabase, MagicRule, MagicStringRule, MagicByteRule, GlobPattern
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \sa QMimeTypeParserBase, MimeTypeParser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeMagicRuleMatcher::QMimeMagicRuleMatcher(const QString& mime, unsigned thePriority) :
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_list(),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_priority(thePriority),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_mimetype(mime)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeMagicRuleMatcher::operator==(const QMimeMagicRuleMatcher& other)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return m_list == other.m_list &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_priority == other.m_priority;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeMagicRuleMatcher::addRule(const QMimeMagicRule& rule)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_list.append(rule);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeMagicRuleMatcher::addRules(const QList<QMimeMagicRule>& rules)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_list.append(rules);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QList<QMimeMagicRule> QMimeMagicRuleMatcher::magicRules() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return m_list;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// Check for a match on contents of a file
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeMagicRuleMatcher::matches(const QByteArray& data) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QMimeMagicRule& magicRule, m_list)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (magicRule.matches(data))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// Return a priority value from 1..100
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++unsigned QMimeMagicRuleMatcher::priority() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return m_priority;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeMagicRuleMatcher_p.hpp lib/MimeHandler/NBMimeMagicRuleMatcher_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..6ba1834
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeMagicRuleMatcher_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,76 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef QMIMEMAGICRULEMATCHER_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QMIMEMAGICRULEMATCHER_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QtCore/qbytearray.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QtCore/qlist.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QtCore/qstring.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeMagicRule_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeMagicRuleMatcher
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ explicit QMimeMagicRuleMatcher(const QString &mime, unsigned priority = 65535);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool operator==(const QMimeMagicRuleMatcher &other);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void addRule(const QMimeMagicRule &rule);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void addRules(const QList<QMimeMagicRule> &rules);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QList<QMimeMagicRule> magicRules() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool matches(const QByteArray &data) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned priority() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString mimetype() const { return m_mimetype; }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QList<QMimeMagicRule> m_list;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned m_priority;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString m_mimetype;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // QMIMEMAGICRULEMATCHER_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeMagicRule_p.hpp lib/MimeHandler/NBMimeMagicRule_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..e074943
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeMagicRule_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,87 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef QMIMEMAGICRULE_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QMIMEMAGICRULE_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QByteArray>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QScopedPointer>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QList>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeMagicRulePrivate;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeMagicRule
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ enum Type { Invalid = 0, String, Host16, Host32, Big16, Big32, Little16, Little32, Byte };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeMagicRule(Type type, const QByteArray &value, int startPos, int endPos, const QByteArray &mask = QByteArray());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeMagicRule(const QMimeMagicRule &other);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ~QMimeMagicRule();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeMagicRule &operator=(const QMimeMagicRule &other);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool operator==(const QMimeMagicRule &other) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Type type() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QByteArray value() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int startPos() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int endPos() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QByteArray mask() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool isValid() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool matches(const QByteArray &data) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QList<QMimeMagicRule> m_subMatches;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static Type type(const QByteArray &type);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QByteArray typeName(Type type);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static bool matchSubstring(const char *dataPtr, int dataSize, int rangeStart, int rangeLength, int valueLength, const char *valueData, const char *mask);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QScopedPointer<QMimeMagicRulePrivate> d;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++Q_DECLARE_TYPEINFO(QMimeMagicRule, Q_MOVABLE_TYPE);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // QMIMEMAGICRULE_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeProvider.cpp lib/MimeHandler/NBMimeProvider.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..6a99853
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeProvider.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,1059 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeProvider_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeTypeParser_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeMagicRuleMatcher_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBStandardPaths.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QXmlStreamReader>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QDir>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QFile>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QByteArrayMatcher>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QDebug>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QDateTime>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QtEndian>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static QString fallbackParent(const QString& mimeTypeName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString myGroup = mimeTypeName.left(mimeTypeName.indexOf(QLatin1Char('/')));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // All text/* types are subclasses of text/plain.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((myGroup == QLatin1String("text")) && (mimeTypeName != QLatin1String("text/plain")))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QLatin1String("text/plain");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // All real-file mimetypes implicitly derive from application/octet-stream
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((myGroup != QLatin1String("inode")) &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ignore non-file extensions
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ (myGroup != QLatin1String("all")) && (myGroup != QLatin1String("fonts")) && (myGroup != QLatin1String("print")) && (myGroup != QLatin1String("uri")) &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ (mimeTypeName != QLatin1String("application/octet-stream")))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QLatin1String("application/octet-stream");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeProviderBase::QMimeProviderBase(QMimeDatabasePrivate *db)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ : m_db(db)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++int qmime_secondsBetweenChecks = 5;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeProviderBase::shouldCheck()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QDateTime now = QDateTime::currentDateTime();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (m_lastCheck.isValid() && (m_lastCheck.secsTo(now) < qmime_secondsBetweenChecks))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_lastCheck = now;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeBinaryProvider::QMimeBinaryProvider(QMimeDatabasePrivate *db)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ : QMimeProviderBase(db), m_mimetypeListLoaded(false)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if defined(Q_OS_UNIX) && !defined(Q_OS_INTEGRITY)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QT_USE_MMAP
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++struct QMimeBinaryProvider::CacheFile
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ CacheFile(const QString& fileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ~CacheFile();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool isValid() const { return m_valid; }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline quint16 getUint16(int offset) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return qFromBigEndian(*reinterpret_cast<quint16 *>(data + offset));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline quint32 getUint32(int offset) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return qFromBigEndian(*reinterpret_cast<quint32 *>(data + offset));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline const char *getCharStar(int offset) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return reinterpret_cast<const char *>(data + offset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool load();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool reload();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFile file;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ uchar *data;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QDateTime m_mtime;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool m_valid;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeBinaryProvider::CacheFile::CacheFile(const QString& fileName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ : file(fileName), m_valid(false)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ load();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeBinaryProvider::CacheFile::~CacheFile()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeBinaryProvider::CacheFile::load()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!file.open(QIODevice::ReadOnly))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data = file.map(0, file.size());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (data)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int major = getUint16(0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int minor = getUint16(2);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_valid = (major == 1 && minor >= 1 && minor <= 2);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_mtime = QFileInfo(file).lastModified();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return m_valid;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeBinaryProvider::CacheFile::reload()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << "reload!" << file->fileName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_valid = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (file.isOpen())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ file.close();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return load();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeBinaryProvider::CacheFile *QMimeBinaryProvider::CacheFileList::findCacheFile(const QString& fileName) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (const_iterator it = begin(); it != end(); ++it)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((*it)->file.fileName() == fileName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return *it;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeBinaryProvider::~QMimeBinaryProvider()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qDeleteAll(m_cacheFiles);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// Position of the "list offsets" values, at the beginning of the mime.cache file
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++enum
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PosAliasListOffset = 4,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PosParentListOffset = 8,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PosLiteralListOffset = 12,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PosReverseSuffixTreeOffset = 16,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PosGlobListOffset = 20,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PosMagicListOffset = 24,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // PosNamespaceListOffset = 28,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PosIconsListOffset = 32,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PosGenericIconsListOffset = 36
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeBinaryProvider::isValid()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if defined(QT_USE_MMAP)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!qgetenv("QT_NO_MIME_CACHE").isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_ASSERT(m_cacheFiles.isEmpty()); // this method is only ever called once
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ checkCache();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (m_cacheFiles.count() > 1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (m_cacheFiles.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // We found exactly one file; is it the user-modified mimes, or a system file?
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString foundFile = m_cacheFiles.first()->file.fileName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString localCacheFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/mime/mime.cache");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return foundFile != localCacheFile;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeBinaryProvider::CacheFileList::checkCacheChanged()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool somethingChanged = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMutableListIterator<CacheFile *> it(*this);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (it.hasNext())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ CacheFile *cacheFile = it.next();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFileInfo fileInfo(cacheFile->file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!fileInfo.exists()) // This can't happen by just running update-mime-database. But the user could use rm -rf :-)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ delete cacheFile;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ it.remove();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ somethingChanged = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (fileInfo.lastModified() > cacheFile->m_mtime)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!cacheFile->reload())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ delete cacheFile;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ it.remove();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ somethingChanged = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return somethingChanged;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeBinaryProvider::checkCache()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!shouldCheck())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // First iterate over existing known cache files and check for uptodate
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (m_cacheFiles.checkCacheChanged())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_mimetypeListLoaded = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Then check if new cache files appeared
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringList cacheFileNames = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/mime.cache"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (cacheFileNames != m_cacheFileNames)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QString& cacheFileName, cacheFileNames)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ CacheFile *cacheFile = m_cacheFiles.findCacheFile(cacheFileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!cacheFile)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << "new file:" << cacheFileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ cacheFile = new CacheFile(cacheFileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (cacheFile->isValid()) // verify version
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_cacheFiles.append(cacheFile);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ delete cacheFile;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_cacheFileNames = cacheFileNames;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_mimetypeListLoaded = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static QMimeType mimeTypeForNameUnchecked(const QString& name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeTypePrivate data;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.name = name;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // The rest is retrieved on demand.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // comment and globPatterns: in loadMimeTypePrivate
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // iconName: in loadIcon
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // genericIconName: in loadGenericIcon
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QMimeType(data);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeBinaryProvider::mimeTypeForName(const QString& name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ checkCache();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!m_mimetypeListLoaded)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ loadMimeTypeList();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!m_mimetypeNames.contains(name))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QMimeType(); // unknown mimetype
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForNameUnchecked(name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QStringList QMimeBinaryProvider::findByFileName(const QString& fileName, QString *foundSuffix)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ checkCache();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (fileName.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QStringList();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString lowerFileName = fileName.toLower();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeGlobMatchResult result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // TODO this parses in the order (local, global). Check that it handles "NOGLOBS" correctly.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(CacheFile * cacheFile, m_cacheFiles)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ matchGlobList(result, cacheFile, cacheFile->getUint32(PosLiteralListOffset), fileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ matchGlobList(result, cacheFile, cacheFile->getUint32(PosGlobListOffset), fileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int reverseSuffixTreeOffset = cacheFile->getUint32(PosReverseSuffixTreeOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int numRoots = cacheFile->getUint32(reverseSuffixTreeOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int firstRootOffset = cacheFile->getUint32(reverseSuffixTreeOffset + 4);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ matchSuffixTree(result, cacheFile, numRoots, firstRootOffset, lowerFileName, fileName.length() - 1, false);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (result.m_matchingMimeTypes.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ matchSuffixTree(result, cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (foundSuffix)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *foundSuffix = result.m_foundSuffix;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return result.m_matchingMimeTypes;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult& result, CacheFile *cacheFile, int off, const QString& fileName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int numGlobs = cacheFile->getUint32(off);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << "Loading" << numGlobs << "globs from" << cacheFile->file.fileName() << "at offset" << cacheFile->globListOffset;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (int i = 0; i < numGlobs; ++i)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int globOffset = cacheFile->getUint32(off + 4 + 12 * i);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int mimeTypeOffset = cacheFile->getUint32(off + 4 + 12 * i + 4);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int flagsAndWeight = cacheFile->getUint32(off + 4 + 12 * i + 8);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int weight = flagsAndWeight & 0xff;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const bool caseSensitive = flagsAndWeight & 0x100;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const Qt::CaseSensitivity qtCaseSensitive = caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString pattern = QLatin1String(cacheFile->getCharStar(globOffset));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *mimeType = cacheFile->getCharStar(mimeTypeOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << pattern << mimeType << weight << caseSensitive;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeGlobPattern glob(pattern, QString() /*unused*/, weight, qtCaseSensitive);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // TODO: this could be done faster for literals where a simple == would do.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (glob.matchFileName(fileName))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ result.addMatch(QLatin1String(mimeType), weight, pattern);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeBinaryProvider::matchSuffixTree(QMimeGlobMatchResult& result, QMimeBinaryProvider::CacheFile *cacheFile, int numEntries, int firstOffset, const QString& fileName, int charPos, bool caseSensitiveCheck)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QChar fileChar = fileName[charPos];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int min = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int max = numEntries - 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (min <= max)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int mid = (min + max) / 2;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int off = firstOffset + 12 * mid;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QChar ch = cacheFile->getUint32(off);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ch < fileChar)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ min = mid + 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (ch > fileChar)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ max = mid - 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ --charPos;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int numChildren = cacheFile->getUint32(off + 4);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int childrenOffset = cacheFile->getUint32(off + 8);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool success = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (charPos > 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ success = matchSuffixTree(result, cacheFile, numChildren, childrenOffset, fileName, charPos, caseSensitiveCheck);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!success)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (int i = 0; i < numChildren; ++i)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int childOff = childrenOffset + 12 * i;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int mch = cacheFile->getUint32(childOff);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (mch != 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int mimeTypeOffset = cacheFile->getUint32(childOff + 4);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *mimeType = cacheFile->getCharStar(mimeTypeOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int flagsAndWeight = cacheFile->getUint32(childOff + 8);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int weight = flagsAndWeight & 0xff;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const bool caseSensitive = flagsAndWeight & 0x100;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (caseSensitiveCheck || !caseSensitive)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ result.addMatch(QLatin1String(mimeType), weight, QLatin1Char('*') + fileName.mid(charPos + 1));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ success = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return success;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeBinaryProvider::matchMagicRule(QMimeBinaryProvider::CacheFile *cacheFile, int numMatchlets, int firstOffset, const QByteArray& data)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *dataPtr = data.constData();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int dataSize = data.size();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (int matchlet = 0; matchlet < numMatchlets; ++matchlet)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int off = firstOffset + matchlet * 32;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int rangeStart = cacheFile->getUint32(off);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int rangeLength = cacheFile->getUint32(off + 4);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //const int wordSize = cacheFile->getUint32(off + 8);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int valueLength = cacheFile->getUint32(off + 12);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int valueOffset = cacheFile->getUint32(off + 16);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int maskOffset = cacheFile->getUint32(off + 20);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *mask = maskOffset ? cacheFile->getCharStar(maskOffset) : NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!QMimeMagicRule::matchSubstring(dataPtr, dataSize, rangeStart, rangeLength, valueLength, cacheFile->getCharStar(valueOffset), mask))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ continue;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int numChildren = cacheFile->getUint32(off + 24);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int firstChildOffset = cacheFile->getUint32(off + 28);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (numChildren == 0) // No submatch? Then we are done.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Check that one of the submatches matches too
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (matchMagicRule(cacheFile, numChildren, firstChildOffset, data))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeBinaryProvider::findByMagic(const QByteArray& data, int *accuracyPtr)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ checkCache();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(CacheFile * cacheFile, m_cacheFiles)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int magicListOffset = cacheFile->getUint32(PosMagicListOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int numMatches = cacheFile->getUint32(magicListOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //const int maxExtent = cacheFile->getUint32(magicListOffset + 4);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int firstMatchOffset = cacheFile->getUint32(magicListOffset + 8);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (int i = 0; i < numMatches; ++i)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int off = firstMatchOffset + i * 16;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int numMatchlets = cacheFile->getUint32(off + 8);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int firstMatchletOffset = cacheFile->getUint32(off + 12);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (matchMagicRule(cacheFile, numMatchlets, firstMatchletOffset, data))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int mimeTypeOffset = cacheFile->getUint32(off + 4);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *mimeType = cacheFile->getCharStar(mimeTypeOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *accuracyPtr = cacheFile->getUint32(off);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Return the first match. We have no rules for conflicting magic data...
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // (mime.cache itself is sorted, but what about local overrides with a lower prio?)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForNameUnchecked(QLatin1String(mimeType));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QMimeType();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QStringList QMimeBinaryProvider::parents(const QString& mime)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ checkCache();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QByteArray mimeStr = mime.toLatin1();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(CacheFile * cacheFile, m_cacheFiles)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int parentListOffset = cacheFile->getUint32(PosParentListOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int numEntries = cacheFile->getUint32(parentListOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int begin = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int end = numEntries - 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (begin <= end)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int medium = (begin + end) / 2;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int off = parentListOffset + 4 + 8 * medium;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int mimeOffset = cacheFile->getUint32(off);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *aMime = cacheFile->getCharStar(mimeOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int cmp = qstrcmp(aMime, mimeStr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (cmp < 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ begin = medium + 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (cmp > 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ end = medium - 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int parentsOffset = cacheFile->getUint32(off + 4);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int numParents = cacheFile->getUint32(parentsOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (int i = 0; i < numParents; ++i)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int parentOffset = cacheFile->getUint32(parentsOffset + 4 + 4 * i);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *aParent = cacheFile->getCharStar(parentOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ result.append(QString::fromLatin1(aParent));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (result.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString parent = fallbackParent(mime);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!parent.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ result.append(parent);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QMimeBinaryProvider::resolveAlias(const QString& name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ checkCache();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QByteArray input = name.toLatin1();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(CacheFile * cacheFile, m_cacheFiles)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int aliasListOffset = cacheFile->getUint32(PosAliasListOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int numEntries = cacheFile->getUint32(aliasListOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int begin = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int end = numEntries - 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (begin <= end)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int medium = (begin + end) / 2;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int off = aliasListOffset + 4 + 8 * medium;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int aliasOffset = cacheFile->getUint32(off);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *alias = cacheFile->getCharStar(aliasOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int cmp = qstrcmp(alias, input);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (cmp < 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ begin = medium + 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (cmp > 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ end = medium - 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int mimeOffset = cacheFile->getUint32(off + 4);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *mimeType = cacheFile->getCharStar(mimeOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QLatin1String(mimeType);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return name;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeBinaryProvider::loadMimeTypeList()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!m_mimetypeListLoaded)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_mimetypeListLoaded = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_mimetypeNames.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Unfortunately mime.cache doesn't have a full list of all mimetypes.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // So we have to parse the plain-text files called "types".
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringList typesFilenames = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/types"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QString& typeFilename, typesFilenames)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFile file(typeFilename);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (file.open(QIODevice::ReadOnly))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (!file.atEnd())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QByteArray line = file.readLine();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ line.chop(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_mimetypeNames.insert(QString::fromLatin1(line.constData(), line.size()));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QList<QMimeType> QMimeBinaryProvider::allMimeTypes()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QList<QMimeType> result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ loadMimeTypeList();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (QSet<QString>::const_iterator it = m_mimetypeNames.constBegin();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ it != m_mimetypeNames.constEnd(); ++it)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ result.append(mimeTypeForNameUnchecked(*it));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate& data)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // load comment and globPatterns
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString file = data.name + QLatin1String(".xml");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringList mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (mimeFiles.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // TODO: ask Thiago about this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qWarning() << "No file found for" << file << ", even though the file appeared in a directory listing.";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qWarning() << "Either it was just removed, or the directory doesn't have executable permission...";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qWarning() << QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime"), QStandardPaths::LocateDirectory);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString comment;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString mainPattern;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString preferredLanguage = QLocale::system().name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QListIterator<QString> mimeFilesIter(mimeFiles);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mimeFilesIter.toBack();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (mimeFilesIter.hasPrevious()) // global first, then local.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString fullPath = mimeFilesIter.previous();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFile qfile(fullPath);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!qfile.open(QFile::ReadOnly))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ continue;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QXmlStreamReader xml(&qfile);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (xml.readNextStartElement())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (xml.name() != QLatin1String("mime-type"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ continue;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString name = xml.attributes().value(QLatin1String("type")).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (name.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ continue;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (name != data.name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qWarning() << "Got name" << name << "in file" << file << "expected" << data.name;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (xml.readNextStartElement())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringRef tag = xml.name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (tag == QLatin1String("comment"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString lang = xml.attributes().value(QLatin1String("xml:lang")).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString text = xml.readElementText();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (lang.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ lang = QLatin1String("en_US");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.localeComments.insert(lang, text);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ continue; // we called readElementText, so we're at the EndElement already.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (tag == QLatin1String("icon")) // as written out by shared-mime-info >= 0.40
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.iconName = xml.attributes().value(QLatin1String("name")).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (tag == QLatin1String("glob-deleteall")) // as written out by shared-mime-info >= 0.70
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.globPatterns.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (tag == QLatin1String("glob")) // as written out by shared-mime-info >= 0.70
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString pattern = xml.attributes().value(QLatin1String("pattern")).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (mainPattern.isEmpty() && pattern.startsWith(QLatin1Char('*')))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ mainPattern = pattern;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!data.globPatterns.contains(pattern))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.globPatterns.append(pattern);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ xml.skipCurrentElement();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_ASSERT(xml.name() == QLatin1String("mime-type"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Let's assume that shared-mime-info is at least version 0.70
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Otherwise we would need 1) a version check, and 2) code for parsing patterns from the globs file.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!mainPattern.isEmpty() && (data.globPatterns.first() != mainPattern))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ensure it's first in the list of patterns
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.globPatterns.removeAll(mainPattern);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.globPatterns.prepend(mainPattern);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const bool globsInXml = sharedMimeInfoVersion() >= QT_VERSION_CHECK(0, 70, 0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (globsInXml)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!mainPattern.isEmpty() && (data.globPatterns.first() != mainPattern))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ensure it's first in the list of patterns
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.globPatterns.removeAll(mainPattern);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.globPatterns.prepend(mainPattern);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Fallback: get the patterns from the globs file
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // TODO: This would be the only way to support shared-mime-info < 0.70
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // But is this really worth the effort?
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// Binary search in the icons or generic-icons list
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QMimeBinaryProvider::iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray& inputMime)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int iconsListOffset = cacheFile->getUint32(posListOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int numIcons = cacheFile->getUint32(iconsListOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int begin = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int end = numIcons - 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (begin <= end)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int medium = (begin + end) / 2;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int off = iconsListOffset + 4 + 8 * medium;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int mimeOffset = cacheFile->getUint32(off);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const char *mime = cacheFile->getCharStar(mimeOffset);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int cmp = qstrcmp(mime, inputMime);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (cmp < 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ begin = medium + 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (cmp > 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ end = medium - 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int iconOffset = cacheFile->getUint32(off + 4);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QLatin1String(cacheFile->getCharStar(iconOffset));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeBinaryProvider::loadIcon(QMimeTypePrivate& data)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ checkCache();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QByteArray inputMime = data.name.toLatin1();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(CacheFile * cacheFile, m_cacheFiles)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString icon = iconForMime(cacheFile, PosIconsListOffset, inputMime);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!icon.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.iconName = icon;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeBinaryProvider::loadGenericIcon(QMimeTypePrivate& data)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ checkCache();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QByteArray inputMime = data.name.toLatin1();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(CacheFile * cacheFile, m_cacheFiles)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString icon = iconForMime(cacheFile, PosGenericIconsListOffset, inputMime);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!icon.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.genericIconName = icon;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++////
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeXMLProvider::QMimeXMLProvider(QMimeDatabasePrivate *db)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ : QMimeProviderBase(db), m_loaded(false)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeXMLProvider::isValid()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeXMLProvider::mimeTypeForName(const QString& name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ensureLoaded();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return m_nameMimeTypeMap.value(name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QStringList QMimeXMLProvider::findByFileName(const QString& fileName, QString *foundSuffix)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ensureLoaded();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringList matchingMimeTypes = m_mimeTypeGlobs.matchingGlobs(fileName, foundSuffix);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return matchingMimeTypes;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType QMimeXMLProvider::findByMagic(const QByteArray& data, int *accuracyPtr)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ensureLoaded();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString candidate;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QMimeMagicRuleMatcher& matcher, m_magicMatchers)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (matcher.matches(data))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int priority = matcher.priority();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (priority > *accuracyPtr)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *accuracyPtr = priority;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ candidate = matcher.mimetype();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return mimeTypeForName(candidate);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeXMLProvider::ensureLoaded()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!m_loaded || shouldCheck())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool fdoXmlFound = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList allFiles;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringList packageDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/packages"), QStandardPaths::LocateDirectory);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << "packageDirs=" << packageDirs;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QString& packageDir, packageDirs)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QDir dir(packageDir);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringList files = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << static_cast<const void *>(this) << Q_FUNC_INFO << packageDir << files;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!fdoXmlFound)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fdoXmlFound = files.contains(QLatin1String("freedesktop.org.xml"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList::const_iterator endIt(files.constEnd());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (QStringList::const_iterator it(files.constBegin()); it != endIt; ++it)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ allFiles.append(packageDir + QLatin1Char('/') + *it);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // if (!fdoXmlFound) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // We could instead install the file as part of installing Qt?
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // allFiles.prepend( QLatin1String( DATA_DIR ) + QLatin1String( "/freedesktop.org.xml" ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (m_allFiles == allFiles)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_allFiles = allFiles;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_nameMimeTypeMap.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_aliases.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_parents.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_mimeTypeGlobs.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_magicMatchers.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << "Loading" << m_allFiles;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QString& file, allFiles)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ load(file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeXMLProvider::load(const QString& fileName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString errorMessage;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!load(fileName, &errorMessage))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qWarning("QMimeDatabase: Error loading %s\n%s", qPrintable(fileName), qPrintable(errorMessage));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeXMLProvider::load(const QString& fileName, QString *errorMessage)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_loaded = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFile file(fileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (errorMessage)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(fileName, file.errorString());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (errorMessage)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ errorMessage->clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeTypeParser parser(*this);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return parser.parse(&file, fileName, errorMessage);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeXMLProvider::addGlobPattern(const QMimeGlobPattern& glob)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_mimeTypeGlobs.addGlob(glob);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeXMLProvider::addMimeType(const QMimeType& mt)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_nameMimeTypeMap.insert(mt.name(), mt);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QStringList QMimeXMLProvider::parents(const QString& mime)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ensureLoaded();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList result = m_parents.value(mime);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (result.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString parent = fallbackParent(mime);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!parent.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ result.append(parent);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeXMLProvider::addParent(const QString& child, const QString& parent)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_parents[child].append(parent);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QMimeXMLProvider::resolveAlias(const QString& name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ensureLoaded();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return m_aliases.value(name, name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeXMLProvider::addAlias(const QString& alias, const QString& name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_aliases.insert(alias, name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QList<QMimeType> QMimeXMLProvider::allMimeTypes()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ensureLoaded();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return m_nameMimeTypeMap.values();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeXMLProvider::addMagicMatcher(const QMimeMagicRuleMatcher& matcher)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ m_magicMatchers.append(matcher);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeProvider_p.hpp lib/MimeHandler/NBMimeProvider_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..23bfe13
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeProvider_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,163 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef QMIMEPROVIDER_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QMIMEPROVIDER_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QDateTime>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeDatabase_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QSet>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeMagicRuleMatcher;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeProviderBase
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeProviderBase(QMimeDatabasePrivate *db);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual ~QMimeProviderBase() {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual bool isValid() = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QMimeType mimeTypeForName(const QString &name) = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QStringList findByFileName(const QString &fileName, QString *foundSuffix) = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QStringList parents(const QString &mime) = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QString resolveAlias(const QString &name) = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QMimeType findByMagic(const QByteArray &data, int *accuracyPtr) = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QList<QMimeType> allMimeTypes() = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual void loadMimeTypePrivate(QMimeTypePrivate &) {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual void loadIcon(QMimeTypePrivate &) {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual void loadGenericIcon(QMimeTypePrivate &) {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeDatabasePrivate *m_db;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++protected:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool shouldCheck();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QDateTime m_lastCheck;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Parses the files 'mime.cache' and 'types' on demand
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeBinaryProvider : public QMimeProviderBase
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeBinaryProvider(QMimeDatabasePrivate *db);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual ~QMimeBinaryProvider();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual bool isValid();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QMimeType mimeTypeForName(const QString &name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QStringList findByFileName(const QString &fileName, QString *foundSuffix);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QStringList parents(const QString &mime);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QString resolveAlias(const QString &name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QMimeType findByMagic(const QByteArray &data, int *accuracyPtr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QList<QMimeType> allMimeTypes();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual void loadMimeTypePrivate(QMimeTypePrivate &);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual void loadIcon(QMimeTypePrivate &);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual void loadGenericIcon(QMimeTypePrivate &);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct CacheFile;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int offset, const QString &fileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool matchSuffixTree(QMimeGlobMatchResult &result, CacheFile *cacheFile, int numEntries, int firstOffset, const QString &fileName, int charPos, bool caseSensitiveCheck);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool matchMagicRule(CacheFile *cacheFile, int numMatchlets, int firstOffset, const QByteArray &data);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray &inputMime);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void loadMimeTypeList();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void checkCache();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ class CacheFileList : public QList<CacheFile *>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ CacheFile *findCacheFile(const QString &fileName) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool checkCacheChanged();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ CacheFileList m_cacheFiles;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList m_cacheFileNames;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QSet<QString> m_mimetypeNames;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool m_mimetypeListLoaded;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Parses the raw XML files (slower)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeXMLProvider : public QMimeProviderBase
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeXMLProvider(QMimeDatabasePrivate *db);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual bool isValid();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QMimeType mimeTypeForName(const QString &name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QStringList findByFileName(const QString &fileName, QString *foundSuffix);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QStringList parents(const QString &mime);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QString resolveAlias(const QString &name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QMimeType findByMagic(const QByteArray &data, int *accuracyPtr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual QList<QMimeType> allMimeTypes();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool load(const QString &fileName, QString *errorMessage);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Called by the mimetype xml parser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void addMimeType(const QMimeType &mt);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void addGlobPattern(const QMimeGlobPattern &glob);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void addParent(const QString &child, const QString &parent);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void addAlias(const QString &alias, const QString &name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void addMagicMatcher(const QMimeMagicRuleMatcher &matcher);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void ensureLoaded();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void load(const QString &fileName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool m_loaded;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ typedef QHash<QString, QMimeType> NameMimeTypeMap;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NameMimeTypeMap m_nameMimeTypeMap;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ typedef QHash<QString, QString> AliasHash;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ AliasHash m_aliases;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ typedef QHash<QString, QStringList> ParentsHash;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParentsHash m_parents;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeAllGlobPatterns m_mimeTypeGlobs;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QList<QMimeMagicRuleMatcher> m_magicMatchers;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList m_allFiles;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // QMIMEPROVIDER_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeType.cpp lib/MimeHandler/NBMimeType.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..0b83d17
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeType.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,537 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeType.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeType_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeDatabase_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeProvider_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeGlobPattern_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QDebug>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QLocale>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <memory>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool qt_isQMimeTypeDebuggingActivated(false);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef QT_NO_DEBUG_OUTPUT
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define DBG() if (qt_isQMimeTypeDebuggingActivated) qDebug() << static_cast<const void *>(this) << Q_FUNC_INFO
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define DBG() if (0) qDebug() << static_cast<const void *>(this) << Q_FUNC_INFO
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeTypePrivate::QMimeTypePrivate()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeTypePrivate::QMimeTypePrivate(const QMimeType& other)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ : name(other.d->name),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ localeComments(other.d->localeComments),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ genericIconName(other.d->genericIconName),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ iconName(other.d->iconName),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ globPatterns(other.d->globPatterns)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeTypePrivate::clear()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ name.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ localeComments.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ genericIconName.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ iconName.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ globPatterns.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn bool QMimeTypePrivate::operator==(const QMimeTypePrivate &other) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns true if \a other equals this QMimeTypePrivate object, otherwise returns false.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeTypePrivate::operator==(const QMimeTypePrivate& other) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((name == other.name) &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ (localeComments == other.localeComments) &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ (genericIconName == other.genericIconName) &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ (iconName == other.iconName) &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ (globPatterns == other.globPatterns))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << name << other.name << (name == other.name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //DBG() << comment << other.comment << (comment == other.comment);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << localeComments << other.localeComments << (localeComments == other.localeComments);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << genericIconName << other.genericIconName << (genericIconName == other.genericIconName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << iconName << other.iconName << (iconName == other.iconName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << globPatterns << other.globPatterns << (globPatterns == other.globPatterns);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void QMimeTypePrivate::addGlobPattern(const QString& pattern)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ globPatterns.append(pattern);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \class QMimeType
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \brief The QMimeType class describes types of file or data, represented by a MIME type string.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \since 5.0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * For instance a file named "readme.txt" has the MIME type "text/plain".
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * The MIME type can be determined from the file name, or from the file
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * contents, or from both. MIME type determination can also be done on
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * buffers of data not coming from files.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Determining the MIME type of a file can be useful to make sure your
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * application supports it. It is also useful in file-manager-like applications
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * or widgets, in order to display an appropriate icon() for the file, or even
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * the descriptive comment() in detailed views.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * To check if a file has the expected MIME type, you should use inherits()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * rather than a simple string comparison based on the name(). This is because
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * MIME types can inherit from each other: for instance a C source file is
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * a specific type of plain text file, so text/x-csrc inherits text/plain.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \sa QMimeDatabase
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QMimeType::QMimeType();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Constructs this QMimeType object initialized with default property values that indicate an invalid MIME type.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType::QMimeType() :
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d(new QMimeTypePrivate())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "name():" << name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //DBG() << "aliases():" << aliases();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //DBG() << "comment():" << comment();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "genericIconName():" << genericIconName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "iconName():" << iconName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "globPatterns():" << globPatterns();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "suffixes():" << suffixes();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "preferredSuffix():" << preferredSuffix();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QMimeType::QMimeType(const QMimeType &other);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Constructs this QMimeType object as a copy of \a other.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType::QMimeType(const QMimeType& other) :
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d(other.d)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "name():" << name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //DBG() << "aliases():" << aliases();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //DBG() << "comment():" << comment();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "genericIconName():" << genericIconName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "iconName():" << iconName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "globPatterns():" << globPatterns();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "suffixes():" << suffixes();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "preferredSuffix():" << preferredSuffix();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QMimeType &QMimeType::operator=(const QMimeType &other);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Assigns the data of \a other to this QMimeType object, and returns a reference to this object.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType& QMimeType::operator=(const QMimeType& other)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (d != other.d)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d = other.d;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return *this;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QMimeType::QMimeType(const QMimeTypePrivate &dd);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Assigns the data of the QMimeTypePrivate \a dd to this QMimeType object, and returns a reference to this object.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType::QMimeType(const QMimeTypePrivate& dd) :
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d(new QMimeTypePrivate(dd))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "name():" << name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //DBG() << "aliases():" << aliases();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //DBG() << "comment():" << comment();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "genericIconName():" << genericIconName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "iconName():" << iconName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "globPatterns():" << globPatterns();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "suffixes():" << suffixes();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "preferredSuffix():" << preferredSuffix();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn void QMimeType::swap(QMimeType &other);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Swaps QMimeType \a other with this QMimeType object.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This operation is very fast and never fails.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * The swap() method helps with the implementation of assignment
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * operators in an exception-safe way. For more information consult
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \l {http://en.wikibooks.org/wiki/More_C++_Idioms/Copy-and-swap}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * {More C++ Idioms - Copy-and-swap}.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QMimeType::~QMimeType();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Destroys the QMimeType object, and releases the d pointer.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeType::~QMimeType()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "name():" << name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //DBG() << "aliases():" << aliases();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //DBG() << "comment():" << comment();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "genericIconName():" << genericIconName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "iconName():" << iconName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "globPatterns():" << globPatterns();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "suffixes():" << suffixes();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DBG() << "preferredSuffix():" << preferredSuffix();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn bool QMimeType::operator==(const QMimeType &other) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns true if \a other equals this QMimeType object, otherwise returns false.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeType::operator==(const QMimeType& other) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d == other.d || *d == *other.d;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn bool QMimeType::operator!=(const QMimeType &other) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns true if \a other does not equal this QMimeType object, otherwise returns false.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn bool QMimeType::isValid() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns true if the QMimeType object contains valid data, otherwise returns false.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * A valid MIME type has a non-empty name().
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * The invalid MIME type is the default-constructed QMimeType.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeType::isValid() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return !d->name.isEmpty();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn bool QMimeType::isDefault() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns true if this MIME type is the default MIME type which
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * applies to all files: application/octet-stream.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeType::isDefault() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->name == QMimeDatabasePrivate::instance()->defaultMimeType();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QString QMimeType::name() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns the name of the MIME type.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QMimeType::name() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->name;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns the description of the MIME type to be displayed on user interfaces.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * The system language (QLocale::system().name()) is used to select the appropriate translation.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QMimeType::comment() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList languageList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ languageList << QLocale::system().name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /*temporally workaround until i learn the code behind the qt 4.8 api for locales */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if QT_VERSION >= 0x040800
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ languageList << QLocale::system().uiLanguages();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_FOREACH (const QString& language, languageList)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString lang = language == QLatin1String("C") ? QLatin1String("en_US") : language;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString comm = d->localeComments.value(lang);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!comm.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return comm;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int pos = lang.indexOf(QLatin1Char('_'));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (pos != -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // "pt_BR" not found? try just "pt"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString shortLang = lang.left(pos);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString commShort = d->localeComments.value(shortLang);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!commShort.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return commShort;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Use the mimetype name as fallback
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->name;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QString QMimeType::genericIconName() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns the file name of a generic icon that represents the MIME type.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This should be used if the icon returned by iconName() cannot be found on
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * the system. It is used for categories of similar types (like spreadsheets
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * or archives) that can use a common icon.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * The freedesktop.org Icon Naming Specification lists a set of such icon names.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * The icon name can be given to QIcon::fromTheme() in order to load the icon.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QMimeType::genericIconName() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeDatabasePrivate::instance()->provider()->loadGenericIcon(*d);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (d->genericIconName.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // From the spec:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // If the generic icon name is empty (not specified by the mimetype definition)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // then the mimetype is used to generate the generic icon by using the top-level
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // media type (e.g. "video" in "video/ogg") and appending "-x-generic"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // (i.e. "video-x-generic" in the previous example).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString group = name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int slashindex = group.indexOf(QLatin1Char('/'));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (slashindex != -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ group = group.left(slashindex);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return group + QLatin1String("-x-generic");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->genericIconName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QString QMimeType::iconName() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns the file name of an icon image that represents the MIME type.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * The icon name can be given to QIcon::fromTheme() in order to load the icon.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QMimeType::iconName() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeDatabasePrivate::instance()->provider()->loadIcon(*d);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (d->iconName.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Make default icon name from the mimetype name
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->iconName = name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int slashindex = d->iconName.indexOf(QLatin1Char('/'));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (slashindex != -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ d->iconName[slashindex] = QLatin1Char('-');
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->iconName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QStringList QMimeType::globPatterns() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns the list of glob matching patterns.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QStringList QMimeType::globPatterns() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return d->globPatterns;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * A type is a subclass of another type if any instance of the first type is
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * also an instance of the second. For example, all image/svg+xml files are also
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * text/xml, text/plain and application/octet-stream files. Subclassing is about
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * the format, rather than the category of the data (for example, there is no
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * 'generic spreadsheet' class that all spreadsheets inherit from).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Conversely, the parent mimetype of image/svg+xml is text/xml.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * A mimetype can have multiple parents. For instance application/x-perl
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * has two parents: application/x-executable and text/plain. This makes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * it possible to both execute perl scripts, and to open them in text editors.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QStringList QMimeType::parentMimeTypes() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QMimeDatabasePrivate::instance()->provider()->parents(d->name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static void collectParentMimeTypes(const QString& mime, QStringList& allParents)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList parents = QMimeDatabasePrivate::instance()->provider()->parents(mime);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QString& parent, parents)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // I would use QSet, but since order matters I better not
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!allParents.contains(parent))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ allParents.append(parent);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // We want a breadth-first search, so that the least-specific parent (octet-stream) is last
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // This means iterating twice, unfortunately.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QString& parent, parents)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ collectParentMimeTypes(parent, allParents);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Return all the parent mimetypes of this mimetype, direct and indirect.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This includes the parent(s) of its parent(s), etc.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * For instance, for image/svg+xml the list would be:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * application/xml, text/plain, application/octet-stream.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Note that application/octet-stream is the ultimate parent for all types
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * of files (but not directories).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QStringList QMimeType::allAncestors() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList allParents;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ collectParentMimeTypes(d->name, allParents);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return allParents;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QStringList QMimeType::suffixes() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns the known suffixes for the MIME type.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QStringList QMimeType::suffixes() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QString& pattern, d->globPatterns)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Not a simple suffix if if looks like: README or *. or *.* or *.JP*G or *.JP?
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (pattern.startsWith(QLatin1String("*.")) &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ (pattern.length() > 2) &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ (pattern.indexOf(QLatin1Char('*'), 2) < 0) && (pattern.indexOf(QLatin1Char('?'), 2) < 0))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString suffix = pattern.mid(2);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ result.append(suffix);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QString QMimeType::preferredSuffix() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns the preferred suffix for the MIME type.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QMimeType::preferredSuffix() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringList suffixList = suffixes();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return suffixList.isEmpty() ? QString() : suffixList.at(0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QString QMimeType::filterString() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns a filter string usable for a file dialog.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QMimeType::filterString() const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString filter;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!d->globPatterns.empty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ filter += comment() + QLatin1String(" (");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (int i = 0; i < d->globPatterns.size(); ++i)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (i != 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ filter += QLatin1Char(' ');
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ filter += d->globPatterns.at(i);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ filter += QLatin1Char(')');
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return filter;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn bool QMimeType::inherits(const QString &mimeTypeName) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns true if this mimetype is \a mimeTypeName,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * or inherits \a mimeTypeName (see parentMimeTypes()),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * or \a mimeTypeName is an alias for this mimetype.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeType::inherits(const QString& mimeTypeName) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (d->name == mimeTypeName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QMimeDatabasePrivate::instance()->inherits(d->name, mimeTypeName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#undef DBG
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeType.hpp lib/MimeHandler/NBMimeType.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..11f655a
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeType.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,111 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#pragma once
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef NBMIMETYPE_HPP
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NBMIMETYPE_HPP
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QSharedData>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QString>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeTypePrivate;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QFileinfo;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QStringList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeType
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType(const QMimeType &other);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType &operator=(const QMimeType &other);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef Q_COMPILER_RVALUE_REFS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeType &operator=(QMimeType &&other)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qSwap(d, other.d);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return *this;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void swap(QMimeType &other)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qSwap(d, other.d);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ explicit QMimeType(const QMimeTypePrivate &dd);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ~QMimeType();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool operator==(const QMimeType &other) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline bool operator!=(const QMimeType &other) const
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return !operator==(other);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool isValid() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool isDefault() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString name() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString comment() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString genericIconName() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString iconName() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList globPatterns() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList parentMimeTypes() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList allAncestors() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList suffixes() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString preferredSuffix() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool inherits(const QString &mimeTypeName) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString filterString() const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++protected:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ friend class QMimeTypeParserBase;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ friend class MimeTypeMapEntry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ friend class QMimeDatabasePrivate;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ friend class QMimeXMLProvider;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ friend class QMimeBinaryProvider;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ friend class QMimeTypePrivate;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QExplicitlySharedDataPointer<QMimeTypePrivate> d;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // QMIMETYPE_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeTypeParser.cpp lib/MimeHandler/NBMimeTypeParser.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..18ef32f
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeTypeParser.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,433 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QT_NO_CAST_FROM_ASCII
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeTypeParser_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeType_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeMagicRuleMatcher_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QCoreApplication>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QDebug>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QDir>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QPair>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QXmlStreamReader>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QXmlStreamWriter>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QStack>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// XML tags in MIME files
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char mimeInfoTagC[] = "mime-info";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char mimeTypeTagC[] = "mime-type";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char mimeTypeAttributeC[] = "type";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char subClassTagC[] = "sub-class-of";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char commentTagC[] = "comment";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char genericIconTagC[] = "generic-icon";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char iconTagC[] = "icon";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char nameAttributeC[] = "name";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char globTagC[] = "glob";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char aliasTagC[] = "alias";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char patternAttributeC[] = "pattern";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char weightAttributeC[] = "weight";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char caseSensitiveAttributeC[] = "case-sensitive";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char localeAttributeC[] = "xml:lang";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char magicTagC[] = "magic";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char priorityAttributeC[] = "priority";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char matchTagC[] = "match";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char matchValueAttributeC[] = "value";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char matchTypeAttributeC[] = "type";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char matchOffsetAttributeC[] = "offset";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static const char matchMaskAttributeC[] = "mask";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \class QMimeTypeParser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \internal
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \brief The QMimeTypeParser class parses MIME types, and builds a MIME database hierarchy by adding to QMimeDatabasePrivate.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Populates QMimeDataBase
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \sa QMimeDatabase, QMimeMagicRuleMatcher, MagicRule, MagicStringRule, MagicByteRule, GlobPattern
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \sa QMimeTypeParser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \class QMimeTypeParserBase
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \internal
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \brief The QMimeTypeParserBase class parses for a sequence of <mime-type> in a generic way.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Calls abstract handler function process for QMimeType it finds.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \sa QMimeDatabase, QMimeMagicRuleMatcher, MagicRule, MagicStringRule, MagicByteRule, GlobPattern
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \sa QMimeTypeParser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn virtual bool QMimeTypeParserBase::process(const QMimeType &t, QString *errorMessage) = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Overwrite to process the sequence of parsed data
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QMimeTypeParserBase::ParseState QMimeTypeParserBase::nextState(ParseState currentState, const QStringRef& startElement)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ switch (currentState)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseBeginning:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (startElement == QLatin1String(mimeInfoTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseMimeInfo;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (startElement == QLatin1String(mimeTypeTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseMimeType;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseError;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseMimeInfo:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return startElement == QLatin1String(mimeTypeTagC) ? ParseMimeType : ParseError;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseMimeType:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseComment:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseGenericIcon:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseIcon:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseGlobPattern:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseSubClass:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseAlias:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseOtherMimeTypeSubTag:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseMagicMatchRule:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (startElement == QLatin1String(mimeTypeTagC)) // Sequence of <mime-type>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseMimeType;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (startElement == QLatin1String(commentTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseComment;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (startElement == QLatin1String(genericIconTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseGenericIcon;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (startElement == QLatin1String(iconTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseIcon;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (startElement == QLatin1String(globTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseGlobPattern;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (startElement == QLatin1String(subClassTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseSubClass;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (startElement == QLatin1String(aliasTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseAlias;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (startElement == QLatin1String(magicTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseMagic;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (startElement == QLatin1String(matchTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseMagicMatchRule;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseOtherMimeTypeSubTag;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseMagic:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (startElement == QLatin1String(matchTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseMagicMatchRule;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseError:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ParseError;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// Parse int number from an (attribute) string)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static bool parseNumber(const QString& n, int *target, QString *errorMessage)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool ok;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *target = n.toInt(&ok);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!ok)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *errorMessage = QString::fromLatin1("Not a number '%1'.").arg(n);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// Evaluate a magic match rule like
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// <match value="must be converted with BinHex" type="string" offset="11"/>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// <match value="0x9501" type="big16" offset="0:64"/>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static bool createMagicMatchRule(const QXmlStreamAttributes& atts,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString *errorMessage, QMimeMagicRule *& rule)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString type = atts.value(QLatin1String(matchTypeAttributeC)).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeMagicRule::Type magicType = QMimeMagicRule::type(type.toLatin1());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (magicType == QMimeMagicRule::Invalid)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qWarning("%s: match type %s is not supported.", Q_FUNC_INFO, type.toUtf8().constData());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString value = atts.value(QLatin1String(matchValueAttributeC)).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (value.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *errorMessage = QString::fromLatin1("Empty match value detected.");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Parse for offset as "1" or "1:10"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int startPos, endPos;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString offsetS = atts.value(QLatin1String(matchOffsetAttributeC)).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const int colonIndex = offsetS.indexOf(QLatin1Char(':'));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString startPosS = colonIndex == -1 ? offsetS : offsetS.mid(0, colonIndex);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString endPosS = colonIndex == -1 ? offsetS : offsetS.mid(colonIndex + 1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!parseNumber(startPosS, &startPos, errorMessage) || !parseNumber(endPosS, &endPos, errorMessage))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString mask = atts.value(QLatin1String(matchMaskAttributeC)).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ rule = new QMimeMagicRule(magicType, value.toUtf8(), startPos, endPos, mask.toLatin1());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++bool QMimeTypeParserBase::parse(QIODevice *dev, const QString& fileName, QString *errorMessage)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeTypePrivate data;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int priority = 50;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStack<QMimeMagicRule *> currentRules; // stack for the nesting of rules
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QList<QMimeMagicRule> rules; // toplevel rules
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QXmlStreamReader reader(dev);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseState ps = ParseBeginning;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QXmlStreamAttributes atts;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (!reader.atEnd())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ switch (reader.readNext())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case QXmlStreamReader::StartElement:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ps = nextState(ps, reader.name());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ atts = reader.attributes();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ switch (ps)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseMimeType:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ { // start parsing a MIME type name
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString name = atts.value(QLatin1String(mimeTypeAttributeC)).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (name.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ reader.raiseError(QString::fromLatin1("Missing '%1'-attribute").arg(QString::fromLatin1(mimeTypeAttributeC)));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.name = name;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseGenericIcon:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.genericIconName = atts.value(QLatin1String(nameAttributeC)).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseIcon:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.iconName = atts.value(QLatin1String(nameAttributeC)).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseGlobPattern:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString pattern = atts.value(QLatin1String(patternAttributeC)).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned weight = atts.value(QLatin1String(weightAttributeC)).toString().toInt();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const bool caseSensitive = atts.value(QLatin1String(caseSensitiveAttributeC)).toString() == QLatin1String("true");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (weight == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ weight = QMimeGlobPattern::DefaultWeight;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_ASSERT(!data.name.isEmpty());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QMimeGlobPattern glob(pattern, data.name, weight, caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!process(glob, errorMessage)) // for actual glob matching
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.addGlobPattern(pattern); // just for QMimeType::globPatterns()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseSubClass:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString inheritsFrom = atts.value(QLatin1String(mimeTypeAttributeC)).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!inheritsFrom.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ processParent(data.name, inheritsFrom);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseComment:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // comments have locale attributes. We want the default, English one
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString locale = atts.value(QLatin1String(localeAttributeC)).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString comment = reader.readElementText();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (locale.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ locale = QString::fromLatin1("en_US");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.localeComments.insert(locale, comment);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseAlias:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString alias = atts.value(QLatin1String(mimeTypeAttributeC)).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!alias.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ processAlias(alias, data.name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseMagic:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ priority = 50;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString priorityS = atts.value(QLatin1String(priorityAttributeC)).toString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!priorityS.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!parseNumber(priorityS, &priority, errorMessage))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ currentRules.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << "MAGIC start for mimetype" << data.name;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseMagicMatchRule:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeMagicRule *rule = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!createMagicMatchRule(atts, errorMessage, rule))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QList<QMimeMagicRule> *ruleList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (currentRules.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ruleList = &rules;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else // nest this rule into the proper parent
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ruleList = ¤tRules.top()->m_subMatches;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ruleList->append(*rule);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << " MATCH added. Stack size was" << currentRules.size();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ currentRules.push(&ruleList->last());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ delete rule;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ParseError:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ reader.raiseError(QString::fromLatin1("Unexpected element <%1>").
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ arg(reader.name().toString()));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ default:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // continue switch QXmlStreamReader::Token...
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case QXmlStreamReader::EndElement: // Finished element
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringRef elementName = reader.name();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (elementName == QLatin1String(mimeTypeTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!process(QMimeType(data), errorMessage))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ data.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (elementName == QLatin1String(matchTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Closing a <match> tag, pop stack
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ currentRules.pop();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << " MATCH closed. Stack size is now" << currentRules.size();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (elementName == QLatin1String(magicTagC))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ //qDebug() << "MAGIC ended, we got" << rules.count() << "rules, with prio" << priority;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Finished a <magic> sequence
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeMagicRuleMatcher ruleMatcher(data.name, priority);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ruleMatcher.addRules(rules);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ processMagicMatcher(ruleMatcher);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ rules.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ default:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (reader.hasError())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (errorMessage)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *errorMessage = QString::fromLatin1("An error has been encountered at line %1 of %2: %3:").arg(reader.lineNumber()).arg(fileName, reader.errorString());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeTypeParser_p.hpp lib/MimeHandler/NBMimeTypeParser_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..e4ad366
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeTypeParser_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,116 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef MIMETYPEPARSER_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define MIMETYPEPARSER_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeDatabase_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeProvider_p.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QIODevice;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeTypeParserBase
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_DISABLE_COPY(QMimeTypeParserBase)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeTypeParserBase() {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual ~QMimeTypeParserBase() {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool parse(QIODevice *dev, const QString &fileName, QString *errorMessage);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++protected:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual bool process(const QMimeType &t, QString *errorMessage) = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual bool process(const QMimeGlobPattern &t, QString *errorMessage) = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual void processParent(const QString &child, const QString &parent) = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual void processAlias(const QString &alias, const QString &name) = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ virtual void processMagicMatcher(const QMimeMagicRuleMatcher &matcher) = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ enum ParseState {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseBeginning,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseMimeInfo,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseMimeType,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseComment,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseGenericIcon,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseIcon,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseGlobPattern,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseSubClass,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseAlias,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseMagic,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseMagicMatchRule,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseOtherMimeTypeSubTag,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ParseError
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static ParseState nextState(ParseState currentState, const QStringRef &startElement);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QMimeTypeParser : public QMimeTypeParserBase
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ explicit QMimeTypeParser(QMimeXMLProvider &provider) : m_provider(provider) {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++protected:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline bool process(const QMimeType &t, QString *)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ { m_provider.addMimeType(t); return true; }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline bool process(const QMimeGlobPattern &glob, QString *)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ { m_provider.addGlobPattern(glob); return true; }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline void processParent(const QString &child, const QString &parent)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ { m_provider.addParent(child, parent); }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline void processAlias(const QString &alias, const QString &name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ { m_provider.addAlias(alias, name); }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ inline void processMagicMatcher(const QMimeMagicRuleMatcher &matcher)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ { m_provider.addMagicMatcher(matcher); }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeXMLProvider &m_provider;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // MIMETYPEPARSER_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/MimeHandler/NBMimeType_p.hpp lib/MimeHandler/NBMimeType_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..6f45530
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/MimeHandler/NBMimeType_p.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,111 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Contact: http://www.qt-project.org/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file is part of the QtCore module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef QMIMETYPE_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QMIMETYPE_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBMimeType.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QHash>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QStringList>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class Q_AUTOTEST_EXPORT QMimeTypePrivate : public QSharedData
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ typedef QHash<QString, QString> LocaleHash;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeTypePrivate();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ explicit QMimeTypePrivate(const QMimeType &other);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool operator==(const QMimeTypePrivate &other) const;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void addGlobPattern(const QString &pattern);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString name;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ LocaleHash localeComments;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString genericIconName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString iconName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList globPatterns;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QMIMETYPE_BUILDER \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QT_BEGIN_NAMESPACE \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QMimeType buildQMimeType ( \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString &name, \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString &genericIconName, \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString &iconName, \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringList &globPatterns \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ) \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ { \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeTypePrivate qMimeTypeData; \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qMimeTypeData.name = name; \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qMimeTypeData.genericIconName = genericIconName; \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qMimeTypeData.iconName = iconName; \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qMimeTypeData.globPatterns = globPatterns; \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QMimeType(qMimeTypeData); \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ } \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef Q_COMPILER_RVALUE_REFS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QMIMETYPE_BUILDER_FROM_RVALUE_REFS \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QT_BEGIN_NAMESPACE \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QMimeType buildQMimeType ( \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString &&name, \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString &&genericIconName, \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString &&iconName, \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList &&globPatterns \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ) \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ { \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QMimeTypePrivate qMimeTypeData; \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qMimeTypeData.name = std::move(name); \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qMimeTypeData.genericIconName = std::move(genericIconName); \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qMimeTypeData.iconName = std::move(iconName); \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qMimeTypeData.globPatterns = std::move(globPatterns); \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QMimeType(qMimeTypeData); \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ } \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // QMIMETYPE_P_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/StandardPaths/NBStandardPaths.cpp lib/StandardPaths/NBStandardPaths.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..c26cd3b
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/StandardPaths/NBStandardPaths.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,306 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** All rights reserved.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Contact: Nokia Corporation (qt-info@nokia.com)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file is part of the QtGui module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBStandardPaths.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QDir>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QFileInfo>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QHash>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QObject>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QCoreApplication>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef QT_NO_STANDARDPATHS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \class QStandardPaths
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \brief The QStandardPaths class provides methods for accessing standard paths.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \since 5.0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This class contains functions to query standard locations on the local
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * filesystem, for common tasks such as user-specific directories or system-wide
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * configuration directories.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \enum QStandardPaths::StandardLocation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This enum describes the different locations that can be queried using
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * methods such as QStandardPaths::writableLocation, QStandardPaths::standardLocations,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * and QStandardPaths::displayName.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value DesktopLocation Returns the user's desktop directory.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value DocumentsLocation Returns the user's document.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value FontsLocation Returns the user's fonts.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value ApplicationsLocation Returns the user's applications.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value MusicLocation Returns the users music.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value MoviesLocation Returns the user's movies.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value PicturesLocation Returns the user's pictures.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value TempLocation Returns the system's temporary directory.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value HomeLocation Returns the user's home directory.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value DataLocation Returns a directory location where persistent
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * application data can be stored. QCoreApplication::organizationName
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * and QCoreApplication::applicationName are appended to the directory location
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * returned for GenericDataLocation.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value CacheLocation Returns a directory location where user-specific
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * non-essential (cached) data should be written.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value GenericDataLocation Returns a directory location where persistent
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * data shared across applications can be stored.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value RuntimeLocation Returns a directory location where runtime communication
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * files should be written. For instance unix local sockets.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value ConfigLocation Returns a directory location where user-specific
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * configuration files should be written.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \sa writableLocation(), standardLocations(), displayName(), locate(), locateAll()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QString QStandardPaths::writableLocation(StandardLocation type)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns the directory where files of \a type should be written to, or an empty string
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * if the location cannot be determined.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \note The storage location returned can be a directory that does not exist; i.e., it
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * may need to be created by the system or the user.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \note On Symbian OS, ApplicationsLocation always point /sys/bin folder on the same drive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * with executable. FontsLocation always points to folder on ROM drive. Symbian OS does not
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * have desktop concept, DesktopLocation returns same path as DocumentsLocation.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Rest of the standard locations point to folder on same drive with executable, except
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * that if executable is in ROM the folder from C drive is returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QStringList QStandardPaths::standardLocations(StandardLocation type)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns all the directories where files of \a type belong.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Much like the PATH variable, it returns the directories in order of priority,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * starting with the user-specific writableLocation() for the \a type.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \enum QStandardPaths::LocateOption
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This enum describes the different flags that can be used for
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * controlling the behavior of QStandardPaths::locate and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * QStandardPaths::locateAll.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value LocateFile return only files
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \value LocateDirectory return only directories
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static bool existsAsSpecified(const QString& path, QStandardPaths::LocateOptions options)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (options & QStandardPaths::LocateDirectory)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QDir(path).exists();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QFileInfo(path).isFile();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Tries to find a file or directory called \a fileName in the standard locations
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * for \a type.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * The full path to the first file or directory (depending on \a options) found is returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * If no such file or directory can be found, an empty string is returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QStandardPaths::locate(StandardLocation type, const QString& fileName, LocateOptions options)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringList dirs = standardLocations(type);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (QStringList::const_iterator dir = dirs.constBegin(); dir != dirs.constEnd(); ++dir)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString path = *dir + QLatin1Char('/') + fileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (existsAsSpecified(path, options))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return path;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Tries to find all files or directories called \a fileName in the standard locations
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * for \a type.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * The \a options flag allows to specify whether to look for files or directories.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns the list of all the files that were found.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QStringList QStandardPaths::locateAll(StandardLocation type, const QString& fileName, LocateOptions options)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QStringList dirs = standardLocations(type);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (QStringList::const_iterator dir = dirs.constBegin(); dir != dirs.constEnd(); ++dir)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString path = *dir + QLatin1Char('/') + fileName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (existsAsSpecified(path, options))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ result.append(path);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef Q_OS_WIN
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static QStringList executableExtensions()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList ret = QString::fromLocal8Bit(qgetenv("PATHEXT")).split(QLatin1Char(';'));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!ret.contains(QLatin1String(".exe"), Qt::CaseInsensitive))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // If %PATHEXT% does not contain .exe, it is either empty, malformed, or distorted in ways that we cannot support, anyway.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ret.clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ret << QLatin1String(".exe")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ << QLatin1String(".com")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ << QLatin1String(".bat")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ << QLatin1String(".cmd");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static QString checkExecutable(const QString& path)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QFileInfo info(path);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (info.isBundle())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return info.bundleName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (info.isFile() && info.isExecutable())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QDir::cleanPath(path);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Finds the executable named \a executableName in the paths specified by \a paths,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * or the system paths if \a paths is empty.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * On most operating systems the system path is determined by the PATH environment variable.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * The directories where to search for the executable can be set in the \a paths argument.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * To search in both your own paths and the system paths, call findExecutable twice, once with
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \a paths set and once with \a paths empty.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Symlinks are not resolved, in order to preserve behavior for the case of executables
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * whose behavior depends on the name they are invoked with.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \note On Windows, the usual executable extensions (from the PATHEXT environment variable)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * are automatically appended, so that for instance findExecutable("foo") will find foo.exe
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * or foo.bat if present.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns the absolute file path to the executable, or an empty string if not found.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QStandardPaths::findExecutable(const QString& executableName, const QStringList& paths)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList searchPaths = paths;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (paths.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QByteArray pEnv = qgetenv("PATH");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QLatin1Char pathSep(';');
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QLatin1Char pathSep(':');
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ searchPaths = QString::fromLocal8Bit(pEnv.constData()).split(pathSep, QString::SkipEmptyParts);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (QFileInfo(executableName).isAbsolute())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return checkExecutable(executableName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QDir currentDir = QDir::current();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString absPath;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef Q_OS_WIN
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QStringList executable_extensions = executableExtensions();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for (QStringList::const_iterator p = searchPaths.constBegin(); p != searchPaths.constEnd(); ++p)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString candidate = currentDir.absoluteFilePath(*p + QLatin1Char('/') + executableName);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef Q_OS_WIN
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString extension = QLatin1Char('.') + QFileInfo(executableName).suffix();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!executable_extensions.contains(extension, Qt::CaseInsensitive))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ foreach(const QString& extension, executable_extensions)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ absPath = checkExecutable(candidate + extension.toLower());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!absPath.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ absPath = checkExecutable(candidate);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!absPath.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return absPath;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*!
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * \fn QString QStandardPaths::displayName(StandardLocation type)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Returns a localized display name for the given location \a type or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * an empty QString if no relevant location can be found.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // QT_NO_STANDARDPATHS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/StandardPaths/NBStandardPaths.hpp lib/StandardPaths/NBStandardPaths.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..efff304
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/StandardPaths/NBStandardPaths.hpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,102 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** All rights reserved.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Contact: Nokia Corporation (qt-info@nokia.com)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file is part of the QtGui module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef QSTANDARDPATHS_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define QSTANDARDPATHS_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QStringList>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_BEGIN_HEADER
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_MODULE(Core)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef QT_NO_STANDARDPATHS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QStringList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class QStandardPaths
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Do not re-order, must match QDesktopServices
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ enum StandardLocation {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DesktopLocation,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DocumentsLocation,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ FontsLocation,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ApplicationsLocation,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ MusicLocation,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ MoviesLocation,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PicturesLocation,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ TempLocation,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ HomeLocation,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ DataLocation,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ CacheLocation,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ GenericDataLocation,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ RuntimeLocation,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ConfigLocation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QString writableLocation(StandardLocation type);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QStringList standardLocations(StandardLocation type);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ enum LocateOption {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ LocateFile = 0x0,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ LocateDirectory = 0x1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_DECLARE_FLAGS(LocateOptions, LocateOption)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QString locate(StandardLocation type, const QString &fileName, LocateOptions options = LocateFile);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QStringList locateAll(StandardLocation type, const QString &fileName, LocateOptions options = LocateFile);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QString displayName(StandardLocation type);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QString findExecutable(const QString &executableName, const QStringList &paths = QStringList());
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // prevent construction
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStandardPaths();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ~QStandardPaths();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // QT_NO_STANDARDPATHS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_HEADER
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // QSTANDARDPATHS_H
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/StandardPaths/NBStandardPaths_unix.cpp lib/StandardPaths/NBStandardPaths_unix.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+new file mode 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 0000000..2a7c1cf
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/StandardPaths/NBStandardPaths_unix.cpp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,322 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** All rights reserved.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Contact: Nokia Corporation (qt-info@nokia.com)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file is part of the QtGui module of the Qt Toolkit.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_BEGIN_LICENSE:LGPL$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU Lesser General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** This file may be used under the terms of the GNU Lesser General Public
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** License version 2.1 as published by the Free Software Foundation and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** appearing in the file LICENSE.LGPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU Lesser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** General Public License version 2.1 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** In addition, as a special exception, Nokia gives you certain additional
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** rights. These rights are described in the Nokia Qt LGPL Exception
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** GNU General Public License Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used under the terms of the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 as published by the Free Software Foundation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** and appearing in the file LICENSE.GPL included in the packaging of this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** file. Please review the following information to ensure the GNU General
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Public License version 3.0 requirements will be met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** http://www.gnu.org/copyleft/gpl.html.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Other Usage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** Alternatively, this file may be used in accordance with the terms and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** conditions contained in a signed written agreement between you and Nokia.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ** $QT_END_LICENSE$
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ **
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ****************************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <NBStandardPaths.hpp>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QProcess>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QUrl>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QDir>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QFile>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QTextStream>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QCoreApplication>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if QT_VERSION <= QT_VERSION_CHECK(4, 7, 0) // i do not sure but for qt 4.7 and 4.6 we need this include
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <QHash>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// LOCAL HACK #include <private/qfilesystemengine_p.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <errno.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <stdlib.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <unistd.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef QT_NO_STANDARDPATHS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QStandardPaths::writableLocation(StandardLocation type)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ switch (type)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case HomeLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QDir::homePath();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case TempLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QDir::tempPath();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case CacheLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString xdgCacheHome = QLatin1String(qgetenv("XDG_CACHE_HOME"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (xdgCacheHome.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!QCoreApplication::organizationName().isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ xdgCacheHome += QLatin1Char('/') + QCoreApplication::organizationName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!QCoreApplication::applicationName().isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ xdgCacheHome += QLatin1Char('/') + QCoreApplication::applicationName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return xdgCacheHome;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case DataLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case GenericDataLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString xdgDataHome = QLatin1String(qgetenv("XDG_DATA_HOME"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (xdgDataHome.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (type == QStandardPaths::DataLocation)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!QCoreApplication::organizationName().isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ xdgDataHome += QLatin1Char('/') + QCoreApplication::organizationName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!QCoreApplication::applicationName().isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ xdgDataHome += QLatin1Char('/') + QCoreApplication::applicationName();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return xdgDataHome;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ConfigLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // http://standards.freedesktop.org/basedir-spec/latest/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (xdgConfigHome.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return xdgConfigHome;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case RuntimeLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const uid_t myUid = geteuid();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // http://standards.freedesktop.org/basedir-spec/latest/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString xdgRuntimeDir = QFile::decodeName(qgetenv("XDG_RUNTIME_DIR"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (xdgRuntimeDir.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString userName = QString(); // LOCAL HACK QFileSystemEngine::resolveUserName(myUid);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ xdgRuntimeDir = QDir::tempPath() + QLatin1String("/runtime-") + userName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QDir dir(xdgRuntimeDir);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!dir.exists())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!QDir().mkdir(xdgRuntimeDir))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qWarning("QStandardPaths: error creating runtime directory %s: %s", qPrintable(xdgRuntimeDir), qPrintable(qt_error_string(errno)));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // "The directory MUST be owned by the user"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFileInfo fileInfo(xdgRuntimeDir);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (fileInfo.ownerId() != myUid)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qWarning("QStandardPaths: wrong ownership on runtime directory %s, %d instead of %d", qPrintable(xdgRuntimeDir),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fileInfo.ownerId(), myUid);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // "and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFile file(xdgRuntimeDir);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((file.permissions() != wantedPerms) && !file.setPermissions(wantedPerms))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ qWarning("QStandardPaths: wrong permissions on runtime directory %s", qPrintable(xdgRuntimeDir));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return xdgRuntimeDir;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ default:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // http://www.freedesktop.org/wiki/Software/xdg-user-dirs
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString xdgConfigHome = QLatin1String(qgetenv("XDG_CONFIG_HOME"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (xdgConfigHome.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QFile file(xdgConfigHome + QLatin1String("/user-dirs.dirs"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (file.exists() && file.open(QIODevice::ReadOnly))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QHash<QString, QString> lines;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QTextStream stream(&file);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QRegExp exp(QLatin1String("^XDG_(.*)_DIR=(.*)$"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (!stream.atEnd())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString line = stream.readLine();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (exp.indexIn(line) != -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList lst = exp.capturedTexts();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString key = lst.at(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString value = lst.at(2);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((value.length() > 2) &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ value.startsWith(QLatin1Char('\"')) &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ value.endsWith(QLatin1Char('\"')))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ value = value.mid(1, value.length() - 2);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Store the key and value: "DESKTOP", "$HOME/Desktop"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ lines[key] = value;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString key;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ switch (type)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case DesktopLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ key = QLatin1String("DESKTOP");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case DocumentsLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ key = QLatin1String("DOCUMENTS");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case PicturesLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ key = QLatin1String("PICTURES");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case MusicLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ key = QLatin1String("MUSIC");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case MoviesLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ key = QLatin1String("VIDEOS");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ default:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!key.isEmpty() && lines.contains(key))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString value = lines[key];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // value can start with $HOME
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (value.startsWith(QLatin1String("$HOME")))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ value = QDir::homePath() + value.mid(5);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return value;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString path;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ switch (type)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case DesktopLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ path = QDir::homePath() + QLatin1String("/Desktop");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case DocumentsLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ path = QDir::homePath() + QLatin1String("/Documents");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case PicturesLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ path = QDir::homePath() + QLatin1String("/Pictures");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case FontsLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ path = QDir::homePath() + QLatin1String("/.fonts");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case MusicLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ path = QDir::homePath() + QLatin1String("/Music");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case MoviesLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ path = QDir::homePath() + QLatin1String("/Videos");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ case ApplicationsLocation:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ path = writableLocation(GenericDataLocation) + QLatin1String("/applications");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ default:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return path;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QStringList QStandardPaths::standardLocations(StandardLocation type)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QStringList dirs;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (type == ConfigLocation)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // http://standards.freedesktop.org/basedir-spec/latest/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString xdgConfigDirs = QFile::decodeName(qgetenv("XDG_CONFIG_DIRS"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (xdgConfigDirs.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dirs.append(QString::fromLatin1("/etc/xdg"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dirs = xdgConfigDirs.split(QLatin1Char(':'));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (type == GenericDataLocation)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // http://standards.freedesktop.org/basedir-spec/latest/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString xdgConfigDirs = QFile::decodeName(qgetenv("XDG_DATA_DIRS"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (xdgConfigDirs.isEmpty())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dirs.append(QString::fromLatin1("/usr/local/share"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dirs.append(QString::fromLatin1("/usr/share"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dirs = xdgConfigDirs.split(QLatin1Char(':'));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ const QString localDir = writableLocation(type);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dirs.prepend(localDir);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return dirs;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QString QStandardPaths::displayName(StandardLocation type)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_UNUSED(type);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return QString();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++QT_END_NAMESPACE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // QT_NO_STANDARDPATHS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/libarchiveqt.h lib/libarchiveqt.h
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index d5188af..f374e73 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/libarchiveqt.h
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/libarchiveqt.h
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,19 +1,27 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-/**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * Copyright 2018-2023 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- **/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Copyright 2018 Britanicus <marcusbritanicus@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is free software: you can redistribute it and/or modify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * it under the terms of the GNU Lesser General Public License as published by
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * the Free Software Foundation, either version 3 of the License, or
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * (at your option) any later version.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This program is distributed in the hope that it will be useful,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * GNU Lesser General Public License for more details.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * You should have received a copy of the GNU Lesser General Public License
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #pragma once
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -26,130 +34,129 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ class QMimeType;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-typedef struct {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Name of the entry */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString name;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++typedef struct
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Name of the entry */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString name;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Size of the entry */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- quint64 size;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Size of the entry */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ quint64 size;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Type of the entry */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int type;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Type of the entry */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int type;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Stat equivalent */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- struct stat info;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Stat equivalent */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ struct stat info;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } ArchiveEntry;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ typedef QList<ArchiveEntry *> ArchiveEntries;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ class LibArchiveQt : public QThread {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_OBJECT
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Q_OBJECT
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Used with updateInputFiles, this helps libarchive to choose how to handle paths */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- enum InputFileMode {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- AbsolutePath = 0x703857, // Use absolute file paths - Discouraged
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- RelativeToRoot, // All paths will be relative to '/' - Useful for packaging of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // installed files
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- RelativeToHome, // Files will have paths relative to home folder - good for saving
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // config files
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- RelativeToCurrent, // The paths will be relative to the current path - Useful for
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // archiving files in current dir [Default]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- RelativeToWorkDir, // Set archive paths of the file relative to @src - @src should be
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // set before calling updateInputFiles
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- CommonRelativePath, // Added files will have paths relative to path common to all files
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // - Costly for large number of files
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++public:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Used with updateInputFiles, this helps libarchive to choose how to handle paths */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ enum InputFileMode
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ AbsolutePath = 0x703857, // Use absolute file paths - Discouraged
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ RelativeToRoot, // All paths will be relative to '/' - Useful for packaging of installed files
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ RelativeToHome, // Files will have paths relative to home folder - good for saving config files
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ RelativeToCurrent, // The paths will be relative to the current path - Useful for archiving files in current dir [Default]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ RelativeToWorkDir, // Set archive paths of the file relative to @src - @src should be set before calling updateInputFiles
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ CommonRelativePath, // Added files will have paths relative to path common to all files - Costly for large number of files
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- LibArchiveQt( QString );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ LibArchiveQt(QString);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // Convenience Functions
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- void updateInputFiles( QStringList, LibArchiveQt::InputFileMode inMode = LibArchiveQt::RelativeToCurrent );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- void setWorkingDir( QString );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- void setDestination( QString );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- void waitForFinished();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Convenience Functions
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void updateInputFiles(QStringList, LibArchiveQt::InputFileMode inMode = LibArchiveQt::RelativeToCurrent);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void setWorkingDir(QString);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void setDestination(QString);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void waitForFinished();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Create an archive */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- void createArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Create an archive */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void createArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Extract the archive */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- void extractArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Extract the archive */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void extractArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Extract a named member of the archive */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- void extractMember( QString );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Extract a named member of the archive */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void extractMember(QString);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* List the contetns of the archive */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ArchiveEntries listArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* List the contetns of the archive */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ArchiveEntries listArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Exit status */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int exitStatus();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Exit status */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int exitStatus();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Convenience functions */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- static QString suffix( QString name );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- static QStringList supportedFormats();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Convenience functions */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QString suffix(QString name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static QStringList supportedFormats();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- enum Mode {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- None = 0xF650E7,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Single,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Container
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++private:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ enum Mode
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ None = 0xF650E7,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Single,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Container
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- enum Job {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- NoJob = 0x25CEE9,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- CreateArchive,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ExtractArchive,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ExtractMember,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ListArchive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ enum Job
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NoJob = 0x25CEE9,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ CreateArchive,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ExtractArchive,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ExtractMember,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ListArchive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Internal worker for copying data */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int copyData( struct archive *ar, struct archive *aw );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Internal worker for copying data */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int copyData(struct archive *ar, struct archive *aw);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Set the archive filter format based on extensions */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- void setFilterFormat( QMimeType mType );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Set the archive filter format based on extensions */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void setFilterFormat(QMimeType mType);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Create an archive - Internal Worker */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- bool doCreateArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Create an archive - Internal Worker */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool doCreateArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Extract the archive - Internal Worker */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- bool doExtractArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Extract the archive - Internal Worker */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool doExtractArchive();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Extract a named member of the archive - Internal Worker */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- bool doExtractMember( QString );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Extract a named member of the archive - Internal Worker */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool doExtractMember(QString);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int mArchiveFilter;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int mArchiveFormat;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int mArchiveFilter;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int mArchiveFormat;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString archiveName;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QHash<QString, QString> inputList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString dest;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString src;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QHash<QString, QString> inputList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString dest;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString src;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ArchiveEntries memberList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- bool readDone;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int archiveType;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ArchiveEntries memberList;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool readDone;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int archiveType;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* What job are we doing? */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int mJob;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* What job are we doing? */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int mJob;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Is the job running? */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- bool isRunning;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Is the job running? */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool isRunning;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Exit status */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int mExitStatus;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Exit status */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int mExitStatus;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Member to be extracted */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QString extractedMember;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Member to be extracted */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QString extractedMember;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- protected:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- void run();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++protected:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void run();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Q_SIGNALS:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- void jobComplete();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- void jobFailed();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++Q_SIGNALS:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void jobComplete();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void jobFailed();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- /* Progress is always in percentage */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- void progress( int );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Progress is always in percentage */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void progress(int);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/lz4dec.c lib/lz4dec.c
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index b11d6ba..6685ba8 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/lz4dec.c
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/lz4dec.c
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -21,8 +21,7 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-// This program is a shorter, more readable, albeit slower re-implementation of lz4cat (
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-// https://github.com/Cyan4973/xxHash )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// This program is a shorter, more readable, albeit slower re-implementation of lz4cat ( https://github.com/Cyan4973/xxHash )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // compile: gcc smallz4cat.c -O3 -o smallz4cat -Wall -pedantic -std=c99 -s
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // The static 8k binary was compiled using Clang and dietlibc (see https://www.fefe.de/dietlibc/ )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -34,7 +33,7 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // Replace getByteFromIn() and sendToOut() by your own code if you need in-memory LZ4 decompression.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // Corrupted data causes a call to error().
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#define READ_BUFFER_SIZE 4 * 1024
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define READ_BUFFER_SIZE 4*1024
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include <stdint.h> // uint32_t
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include <stdio.h> // stdin/stdout/stderr, fopen, ...
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -44,296 +43,273 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include "lz4dec.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // error handler
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-void error( const char *msg ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // smaller static binary than fprintf(stderr, "ERROR: %s\n", msg);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fputs( "ERROR: ", stderr );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fputs( msg, stderr );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fputs( "\n", stderr );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- exit( 1 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void error(const char* msg) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // smaller static binary than fprintf(stderr, "ERROR: %s\n", msg);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fputs("ERROR: ", stderr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fputs(msg, stderr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fputs("\n", stderr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ exit( 1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ static unsigned char getByte( FILE *in ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // modify buffer size as you like ... for most use cases, bigger buffer aren't faster anymore - and even
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // reducing to 1 byte works !
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- static unsigned char readBuffer[ READ_BUFFER_SIZE ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- static size_t pos = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- static size_t available = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // refill buffer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( pos == available ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- pos = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- available = fread( readBuffer, 1, READ_BUFFER_SIZE, in );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( available == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- error( "out of data" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // return a byte
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return readBuffer[ pos++ ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // modify buffer size as you like ... for most use cases, bigger buffer aren't faster anymore - and even reducing to 1 byte works !
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static unsigned char readBuffer[READ_BUFFER_SIZE];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static size_t pos = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ static size_t available = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // refill buffer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (pos == available)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ pos = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ available = fread(readBuffer, 1, READ_BUFFER_SIZE, in);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (available == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ error("out of data");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // return a byte
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return readBuffer[pos++];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-static void sendBytes( const unsigned char *data, unsigned int numBytes, FILE *out ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( (data != NULL) && (numBytes > 0) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fwrite( data, 1, numBytes, out );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static void sendBytes(const unsigned char* data, unsigned int numBytes, FILE *out) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (data != NULL && numBytes > 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fwrite(data, 1, numBytes, out);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-void unlz4( const char *ifn, const char *ofn, const char *dictionary ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- FILE *inpFp = fopen( ifn, "rb" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- FILE *outFp = fopen( ofn, "wb" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // signature
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char signature1 = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char signature2 = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char signature3 = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char signature4 = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- uint32_t signature = (signature4 << 24) | (signature3 << 16) | (signature2 << 8) | signature1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int isModern = (signature == 0x184D2204);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- int isLegacy = (signature == 0x184C2102);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( !isModern && !isLegacy ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- error( "invalid signature" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char hasBlockChecksum = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char hasContentSize = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char hasContentChecksum = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char hasDictionaryID = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( isModern ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // flags
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char flags = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- hasBlockChecksum = flags & 16;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- hasContentSize = flags & 8;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- hasContentChecksum = flags & 4;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- hasDictionaryID = flags & 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // only version 1 file format
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char version = flags >> 6;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( version != 1 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- error( "only LZ4 file format version 1 supported" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // ignore blocksize
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( hasContentSize ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // ignore, skip 8 bytes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( hasDictionaryID ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // ignore, skip 4 bytes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // ignore header checksum (xxhash32 of everything up this point & 0xFF)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // don't lower this value, backreferences can be 64kb far away
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#define HISTORY_SIZE 64 * 1024
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // contains the latest decoded data
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char history[ HISTORY_SIZE ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // next free position in history[]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned int pos = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // dictionary compression is a recently introduced feature, just move its contents to the buffer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( dictionary != NULL ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // open dictionary
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- FILE *dict = fopen( dictionary, "rb" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( !dict ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- error( "cannot open dictionary" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // get dictionary's filesize
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fseek( dict, 0, SEEK_END );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- size_t dictSize = ftell( dict );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // only the last 64k are relevant
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- size_t relevant = dictSize < 65536 ? 0 : dictSize - 65536;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fseek( dict, (long)relevant, SEEK_SET );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( dictSize > 65536 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- dictSize = 65536;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // read it and store it at the end of the buffer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fread( history + HISTORY_SIZE - dictSize, 1, dictSize, dict );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fclose( dict );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // parse all blocks until blockSize == 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( 1 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // block size
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- uint32_t blockSize = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- blockSize |= (uint32_t)getByte( inpFp ) << 8;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- blockSize |= (uint32_t)getByte( inpFp ) << 16;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- blockSize |= (uint32_t)getByte( inpFp ) << 24;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // highest bit set ?
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char isCompressed = isLegacy || (blockSize & 0x80000000) == 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( isModern ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- blockSize &= 0x7FFFFFFF;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // stop after last block
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( blockSize == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( isCompressed ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // decompress block
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- uint32_t blockOffset = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( blockOffset < blockSize ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // get a token
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char token = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- blockOffset++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // determine number of literals
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- uint32_t numLiterals = (token >> 4) & 0x0F;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( numLiterals == 15 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // number of literals length encoded in more than 1 byte
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char current;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- do{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- current = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- numLiterals += current;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- blockOffset++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- } while ( current == 255 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- blockOffset += numLiterals;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // copy all those literals
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( numLiterals-- > 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- history[ pos++ ] = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // flush output buffer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( pos == HISTORY_SIZE ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- sendBytes( history, HISTORY_SIZE, outFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- pos = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // last token has only literals
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( blockOffset == blockSize ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // match distance is encoded by two bytes (little endian)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- blockOffset += 2;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- uint32_t delta = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- delta |= (uint32_t)getByte( inpFp ) << 8;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // zero isn't allowed
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( delta == 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- error( "invalid offset" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // match length (must be >= 4, therefore length is stored minus 4)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- uint32_t matchLength = 4 + (token & 0x0F);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( matchLength == 4 + 0x0F ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- unsigned char current;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- do{ // match length encoded in more than 1 byte
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- current = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- matchLength += current;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- blockOffset++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- } while ( current == 255 );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // copy match
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- uint32_t reference = (pos >= delta) ? pos - delta : HISTORY_SIZE + pos - delta;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( (pos + matchLength < HISTORY_SIZE) && (reference + matchLength < HISTORY_SIZE) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // fast copy
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( (pos >= reference + matchLength) || (reference >= pos + matchLength) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // non-overlapping
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- memcpy( history + pos, history + reference, matchLength );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- pos += matchLength;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // overlapping
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( matchLength-- > 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- history[ pos++ ] = history[ reference++ ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // slower copy, have to take care of buffer limits
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( matchLength-- > 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // copy single byte
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- history[ pos++ ] = history[ reference++ ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // cannot write anymore ? => wrap around
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( pos == HISTORY_SIZE ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // flush output buffer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- sendBytes( history, HISTORY_SIZE, outFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- pos = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // cannot read anymore ? => wrap around
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( reference == HISTORY_SIZE ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- reference = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // all legacy blocks must be completely filled - except for the last one
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( isLegacy && (blockSize < 8 * 1024 * 1024) ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // copy uncompressed data and add to history, too (if next block is compressed and some matches
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // refer to this block)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- while ( blockSize-- > 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // copy a byte ...
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- history[ pos++ ] = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // ... until buffer is full => send to output
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( pos == HISTORY_SIZE ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- sendBytes( history, HISTORY_SIZE, outFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- pos = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( hasBlockChecksum ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // ignore checksum, skip 4 bytes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if ( hasContentChecksum ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // ignore checksum, skip 4 bytes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- // flush output buffer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- sendBytes( history, pos, outFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void unlz4( const char *ifn, const char *ofn, const char* dictionary) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ FILE *inpFp = fopen( ifn, "rb" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ FILE *outFp = fopen( ofn, "wb" );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // signature
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char signature1 = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char signature2 = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char signature3 = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char signature4 = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ uint32_t signature = (signature4 << 24) | (signature3 << 16) | (signature2 << 8) | signature1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int isModern = (signature == 0x184D2204);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int isLegacy = (signature == 0x184C2102);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!isModern && !isLegacy)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ error("invalid signature");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char hasBlockChecksum = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char hasContentSize = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char hasContentChecksum = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char hasDictionaryID = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (isModern) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // flags
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char flags = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ hasBlockChecksum = flags & 16;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ hasContentSize = flags & 8;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ hasContentChecksum = flags & 4;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ hasDictionaryID = flags & 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // only version 1 file format
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char version = flags >> 6;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (version != 1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ error("only LZ4 file format version 1 supported");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ignore blocksize
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (hasContentSize)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ignore, skip 8 bytes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ getByte( inpFp ); getByte( inpFp ); getByte( inpFp ); getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ getByte( inpFp ); getByte( inpFp ); getByte( inpFp ); getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (hasDictionaryID)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ignore, skip 4 bytes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ getByte( inpFp ); getByte( inpFp ); getByte( inpFp ); getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ignore header checksum (xxhash32 of everything up this point & 0xFF)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // don't lower this value, backreferences can be 64kb far away
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define HISTORY_SIZE 64*1024
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // contains the latest decoded data
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char history[HISTORY_SIZE];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // next free position in history[]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned int pos = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // dictionary compression is a recently introduced feature, just move its contents to the buffer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (dictionary != NULL)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // open dictionary
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ FILE* dict = fopen(dictionary, "rb");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!dict)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ error("cannot open dictionary");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // get dictionary's filesize
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fseek(dict, 0, SEEK_END);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ size_t dictSize = ftell(dict);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // only the last 64k are relevant
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ size_t relevant = dictSize < 65536 ? 0 : dictSize - 65536;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fseek(dict, (long)relevant, SEEK_SET);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (dictSize > 65536)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dictSize = 65536;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // read it and store it at the end of the buffer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fread(history + HISTORY_SIZE - dictSize, 1, dictSize, dict);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ fclose(dict);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // parse all blocks until blockSize == 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // block size
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ uint32_t blockSize = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ blockSize |= (uint32_t)getByte( inpFp ) << 8;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ blockSize |= (uint32_t)getByte( inpFp ) << 16;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ blockSize |= (uint32_t)getByte( inpFp ) << 24;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // highest bit set ?
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char isCompressed = isLegacy || (blockSize & 0x80000000) == 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (isModern)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ blockSize &= 0x7FFFFFFF;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // stop after last block
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (blockSize == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (isCompressed)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // decompress block
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ uint32_t blockOffset = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (blockOffset < blockSize)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // get a token
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char token = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ blockOffset++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // determine number of literals
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ uint32_t numLiterals = (token >> 4) & 0x0F;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (numLiterals == 15)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // number of literals length encoded in more than 1 byte
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char current;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ do
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ current = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ numLiterals += current;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ blockOffset++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ } while (current == 255);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ blockOffset += numLiterals;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // copy all those literals
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (numLiterals-- > 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ history[pos++] = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // flush output buffer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (pos == HISTORY_SIZE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ sendBytes(history, HISTORY_SIZE, outFp);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ pos = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // last token has only literals
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (blockOffset == blockSize)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // match distance is encoded by two bytes (little endian)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ blockOffset += 2;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ uint32_t delta = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ delta |= (uint32_t)getByte( inpFp ) << 8;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // zero isn't allowed
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (delta == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ error("invalid offset");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // match length (must be >= 4, therefore length is stored minus 4)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ uint32_t matchLength = 4 + (token & 0x0F);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (matchLength == 4 + 0x0F)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned char current;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ do // match length encoded in more than 1 byte
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ current = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ matchLength += current;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ blockOffset++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ } while (current == 255);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // copy match
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ uint32_t reference = (pos >= delta) ? pos - delta : HISTORY_SIZE + pos - delta;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (pos + matchLength < HISTORY_SIZE && reference + matchLength < HISTORY_SIZE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // fast copy
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (pos >= reference + matchLength || reference >= pos + matchLength)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // non-overlapping
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ memcpy(history + pos, history + reference, matchLength);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ pos += matchLength;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // overlapping
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (matchLength-- > 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ history[pos++] = history[reference++];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // slower copy, have to take care of buffer limits
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (matchLength-- > 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // copy single byte
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ history[pos++] = history[reference++];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // cannot write anymore ? => wrap around
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (pos == HISTORY_SIZE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // flush output buffer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ sendBytes(history, HISTORY_SIZE, outFp);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ pos = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // cannot read anymore ? => wrap around
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (reference == HISTORY_SIZE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ reference = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // all legacy blocks must be completely filled - except for the last one
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (isLegacy && blockSize < 8*1024*1024)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // copy uncompressed data and add to history, too (if next block is compressed and some matches refer to this block)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (blockSize-- > 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // copy a byte ...
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ history[pos++] = getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ... until buffer is full => send to output
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (pos == HISTORY_SIZE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ sendBytes(history, HISTORY_SIZE, outFp);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ pos = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (hasBlockChecksum)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ignore checksum, skip 4 bytes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ getByte( inpFp ); getByte( inpFp ); getByte( inpFp ); getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (hasContentChecksum)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ignore checksum, skip 4 bytes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ getByte( inpFp ); getByte( inpFp ); getByte( inpFp ); getByte( inpFp );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // flush output buffer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ sendBytes(history, pos, outFp);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/lz4dec.h lib/lz4dec.h
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index daf72d2..e1d1a96 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/lz4dec.h
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/lz4dec.h
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,7 +1,9 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-/**
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- * lz4dec.h - Lz4 decompression header
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- **/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * lz4dec.h - Lz4 decompression header
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #pragma once
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-void unlz4( const char *, const char *, const char * );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++void unlz4(const char *, const char *, const char *);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git lib/meson.build lib/meson.build
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index ff87c69..a95b987 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- lib/meson.build
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ lib/meson.build
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -16,6 +16,36 @@ Sources = [
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 'lz4dec.c'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++if ( QtCore.version().startswith( '4.' ) )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ warning( 'We strongly advice against using Qt4.' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Headers += [
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeDatabase.hpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeDatabase_p.hpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeGlobPattern_p.hpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeMagicRule_p.hpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeMagicRuleMatcher_p.hpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeProvider_p.hpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeType.hpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeType_p.hpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeTypeParser_p.hpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'StandardPaths/NBStandardPaths.hpp'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Sources += [
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeDatabase.cpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeDatabase.cpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeGlobPattern.cpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeMagicRule.cpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeMagicRuleMatcher.cpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeProvider.cpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeType.cpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'MimeHandler/NBMimeTypeParser.cpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'StandardPaths/NBStandardPaths_unix.cpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'StandardPaths/NBStandardPaths.cpp'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Mocs = Qt.compile_moc(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ headers : Headers,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dependencies: Deps
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -23,8 +53,8 @@ Mocs = Qt.compile_moc(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ shared = shared_library(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ TgtName, [ Sources, Mocs ],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- version: meson.project_version(),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- include_directories: Includes,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ version: meson.project_version(),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ include_directories: Includes,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dependencies: Deps,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ install: true,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ link_args: ['-rdynamic','-fPIC'],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -33,7 +63,7 @@ shared = shared_library(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ static = static_library(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ TgtName, [ Sources, Mocs ],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- include_directories: Includes,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ include_directories: Includes,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dependencies: Deps,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ install: get_option( 'install_static' ),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ install_dir: join_paths( get_option( 'libdir' ) )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -44,21 +74,21 @@ install_headers(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ArchiveQtShared = declare_dependency(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- link_with: shared,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ link_with: shared,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ArchiveQtStatic = declare_dependency(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- link_with: static,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ link_with: static,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ## PkgConfig Section
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ pkgconfig = import( 'pkgconfig' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ pkgconfig.generate(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- shared,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- name: TgtName,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- version: meson.project_version(),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- filebase: TgtName,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- description: 'A Qt based archiving solution with libarchive backend',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- requires: [ QtCore.name(), Zlib.name(), Lzma.name(), Archive.name() ],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ shared,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ name: TgtName,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ version: meson.project_version(),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ filebase: TgtName,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ description: 'A Qt based archiving solution with libarchive backend',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ requires: [ QtCore.name(), Zlib.name(), Lzma.name(), Archive.name() ],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ libraries: [ '-lbz2' ]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git meson.build meson.build
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 1cd1cca..7ad65d8 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- meson.build
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ meson.build
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -2,7 +2,7 @@ project(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 'Archive Qt',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 'c',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 'cpp',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- version: '2.0.8',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ version: '2.0.7',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ license: 'GPLv3',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ meson_version: '>=0.59.0',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ default_options: [
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -21,24 +21,43 @@ Lzma = dependency( 'liblzma' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ BZip = meson.get_compiler( 'cpp' ).find_library( 'bz2' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Archive = dependency( 'libarchive' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-if get_option('use_qt_version') == 'qt5'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Qt = import( 'qt5' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QtCore = dependency( 'Qt5Core' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- TgtName = 'archiveqt5'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++if get_option('use_qt_version') == 'qt4'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Qt = import( 'qt4' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QtCore = dependency( 'QtCore' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ TgtName = 'archiveqt4'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++elif get_option('use_qt_version') == 'qt5'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Qt = import( 'qt5' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QtCore = dependency( 'Qt5Core' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ TgtName = 'archiveqt5'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ elif get_option('use_qt_version') == 'qt6'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- Qt = import( 'qt6' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- QtCore = dependency( 'Qt6Core' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- TgtName = 'archiveqt6'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Qt = import( 'qt6' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ QtCore = dependency( 'Qt6Core' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ TgtName = 'archiveqt6'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Deps = [ QtCore, Zlib, Lzma, BZip, Archive ]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-Includes = include_directories( 'lib' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++Includes = include_directories(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'lib',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'lib/MimeHandler',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'lib/StandardPaths',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Contains the main library
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ subdir( 'lib' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Contains the archvier cli app
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ subdir( 'archiver' )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++summary = [
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ '',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ '----------------',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ 'Archive Qt @0@'.format(meson.project_version()),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ '----------------',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ''
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++message('\n'.join(summary))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git meson_options.txt meson_options.txt
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 157d261..62c66b9 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- meson_options.txt
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ meson_options.txt
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1,7 +1,7 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ option(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 'use_qt_version',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ type: 'combo',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- choices: ['qt5', 'qt6'],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ choices: ['qt4', 'qt5', 'qt6'],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ value: 'qt5',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ description: 'Select the Qt version to use'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ )
</span></pre><pre style='margin:0'>
</pre>