Changeset View
Changeset View
Standalone View
Standalone View
plugins/libzipplugin/libzipplugin.cpp
Show All 21 Lines | |||||
22 | * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF | 22 | * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF | ||
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | */ | 24 | */ | ||
25 | 25 | | |||
26 | #include "libzipplugin.h" | 26 | #include "libzipplugin.h" | ||
27 | #include "ark_debug.h" | 27 | #include "ark_debug.h" | ||
28 | #include "queries.h" | 28 | #include "queries.h" | ||
29 | 29 | | |||
30 | #include <KIO/Global> | ||||
30 | #include <KLocalizedString> | 31 | #include <KLocalizedString> | ||
31 | #include <KPluginFactory> | 32 | #include <KPluginFactory> | ||
32 | 33 | | |||
33 | #include <QDataStream> | 34 | #include <QDataStream> | ||
34 | #include <QDateTime> | 35 | #include <QDateTime> | ||
35 | #include <QDir> | 36 | #include <QDir> | ||
36 | #include <QDirIterator> | 37 | #include <QDirIterator> | ||
37 | #include <QFile> | 38 | #include <QFile> | ||
▲ Show 20 Lines • Show All 596 Lines • ▼ Show 20 Line(s) | 628 | while (sum != sb.size) { | |||
634 | if (out.writeRawData(buf, len) != len) { | 635 | if (out.writeRawData(buf, len) != len) { | ||
635 | qCCritical(ARK) << "Failed to write data"; | 636 | qCCritical(ARK) << "Failed to write data"; | ||
636 | emit error(xi18n("Failed to write data for entry: %1", entry)); | 637 | emit error(xi18n("Failed to write data for entry: %1", entry)); | ||
637 | return false; | 638 | return false; | ||
638 | } | 639 | } | ||
639 | 640 | | |||
640 | sum += len; | 641 | sum += len; | ||
641 | } | 642 | } | ||
643 | | ||||
644 | const auto index = zip_name_locate(archive, entry.toUtf8(), ZIP_FL_ENC_GUESS); | ||||
645 | if (index == -1) { | ||||
646 | qCCritical(ARK) << "Could not locate entry:" << entry; | ||||
647 | emit error(xi18n("Failed to locate entry: %1", entry)); | ||||
648 | return false; | ||||
649 | } | ||||
650 | | ||||
651 | zip_uint8_t opsys; | ||||
652 | zip_uint32_t attributes; | ||||
653 | if (zip_file_get_external_attributes(archive, index, ZIP_FL_UNCHANGED, &opsys, &attributes) == -1) { | ||||
654 | qCCritical(ARK) << "Could not read external attributes for entry:" << entry; | ||||
655 | emit error(xi18n("Failed to read metadata for entry: %1", entry)); | ||||
656 | return false; | ||||
657 | } | ||||
658 | | ||||
659 | // Inspired by fuse-zip source code: fuse-zip/lib/fileNode.cpp | ||||
660 | switch (opsys) { | ||||
661 | case ZIP_OPSYS_UNIX: | ||||
662 | // Unix permissions are stored in the leftmost 16 bits of the external file attribute. | ||||
663 | file.setPermissions(KIO::convertPermissions(attributes >> 16)); | ||||
664 | break; | ||||
665 | default: // TODO: non-UNIX. | ||||
666 | break; | ||||
667 | } | ||||
668 | | ||||
669 | | ||||
642 | return true; | 670 | return true; | ||
643 | } | 671 | } | ||
644 | 672 | | |||
645 | bool LibzipPlugin::moveFiles(const QVector<Archive::Entry*> &files, Archive::Entry *destination, const CompressionOptions &options) | 673 | bool LibzipPlugin::moveFiles(const QVector<Archive::Entry*> &files, Archive::Entry *destination, const CompressionOptions &options) | ||
646 | { | 674 | { | ||
647 | Q_UNUSED(options) | 675 | Q_UNUSED(options) | ||
648 | 676 | | |||
649 | int errcode; | 677 | int errcode; | ||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |