From 355a25b1722620a09acc9ea8a125e44d2ef572e3 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 29 Sep 2015 15:44:30 +0200 Subject: [PATCH] fixed symlinks --- alpm/mingwbundle.cpp | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/alpm/mingwbundle.cpp b/alpm/mingwbundle.cpp index 25a4208..cdc5ee7 100644 --- a/alpm/mingwbundle.cpp +++ b/alpm/mingwbundle.cpp @@ -135,20 +135,26 @@ enum class RelevantFileArch struct RelevantFile { - RelevantFile(const KArchiveFile *file, const RelevantFileType type, const RelevantFileArch arch, const QString &subDir = QString()) : + RelevantFile(const KArchiveFile *file, const KArchiveDirectory *containingDir, const RelevantFileType type, const RelevantFileArch arch, const QString &subDir = QString()) : name(file->name()), - data(file->data()), fileType(type), arch(arch), - subDir(subDir), - symlinkTarget(file->symLinkTarget()) - {} + subDir(subDir) + { + if(file->symLinkTarget().isEmpty()) { + data = file->data(); + } else if(const auto *targetEntry = containingDir->entry(file->symLinkTarget())) { + // Windows support for symlinks is not very well + if(targetEntry->isFile()) { + data = static_cast(targetEntry)->data(); + } + } + } QString name; QByteArray data; RelevantFileType fileType; RelevantFileArch arch; QString subDir; - QString symlinkTarget; }; struct PkgFileInfo @@ -173,7 +179,7 @@ void addEntries(PkgFileInfo &pkgFileInfo, RelevantFileType fileType, const KArch if(entry->isDirectory()) { addEntries(pkgFileInfo, fileType, static_cast(entry), newPath); } else if(entry->isFile()) { - pkgFileInfo.relevantFiles.emplace_back(static_cast(entry), fileType, RelevantFileArch::Any, newPath); + pkgFileInfo.relevantFiles.emplace_back(static_cast(entry), dir, fileType, RelevantFileArch::Any, newPath); } } } @@ -198,7 +204,7 @@ void getFiles(PkgFileInfo &pkgFileInfo) if(entryName.endsWith(QLatin1String(".exe")) || entryName.endsWith(QLatin1String(".dll"))) { if(const auto *entry = binDir->entry(entryName)) { if(entry->isFile()) { - pkgFileInfo.relevantFiles.emplace_back(static_cast(entry), RelevantFileType::Binary, root.first); + pkgFileInfo.relevantFiles.emplace_back(static_cast(entry), binDir, RelevantFileType::Binary, root.first); } } } @@ -220,7 +226,7 @@ void getFiles(PkgFileInfo &pkgFileInfo) for(const auto &entryName : categoryDir->entries()) { if(const auto *pluginEntry = categoryDir->entry(entryName)) { if(pluginEntry->isFile()) { - pkgFileInfo.relevantFiles.emplace_back(static_cast(pluginEntry), RelevantFileType::QtPlugin, root.first, categoryDir->name()); + pkgFileInfo.relevantFiles.emplace_back(static_cast(pluginEntry), categoryDir, RelevantFileType::QtPlugin, root.first, categoryDir->name()); } } } @@ -242,7 +248,7 @@ void getFiles(PkgFileInfo &pkgFileInfo) if(entryName.endsWith(QLatin1String(".qm"))) { if(const auto *qmEntry = trDir->entry(entryName)) { if(qmEntry->isFile()) { - pkgFileInfo.relevantFiles.emplace_back(static_cast(qmEntry), RelevantFileType::QtTranslation, root.first); + pkgFileInfo.relevantFiles.emplace_back(static_cast(qmEntry), trDir, RelevantFileType::QtTranslation, root.first); } } } @@ -256,7 +262,7 @@ void getFiles(PkgFileInfo &pkgFileInfo) for(const auto &entryName : appDir->entries()) { const auto *entry = appDir->entry(entryName); if(entry->isFile()) { - pkgFileInfo.relevantFiles.emplace_back(static_cast(entry), RelevantFileType::ConfigFile, root.first); + pkgFileInfo.relevantFiles.emplace_back(static_cast(entry), appDir, RelevantFileType::ConfigFile, root.first); } else { const auto subDir = static_cast(entry); if(entryName == QLatin1String("translations")) { @@ -264,7 +270,7 @@ void getFiles(PkgFileInfo &pkgFileInfo) if(entryName.endsWith(QLatin1String(".qm"))) { if(const auto *qmEntry = subDir->entry(entryName)) { if(qmEntry->isFile()) { - pkgFileInfo.relevantFiles.emplace_back(static_cast(qmEntry), RelevantFileType::Translation, root.first); + pkgFileInfo.relevantFiles.emplace_back(static_cast(qmEntry), subDir, RelevantFileType::Translation, root.first); } } } @@ -273,7 +279,7 @@ void getFiles(PkgFileInfo &pkgFileInfo) for(const auto &entryName : subDir->entries()) { if(const auto *configEntry = subDir->entry(entryName)) { if(configEntry->isFile()) { - pkgFileInfo.relevantFiles.emplace_back(static_cast(configEntry), RelevantFileType::ConfigFile, root.first, subDir->name()); + pkgFileInfo.relevantFiles.emplace_back(static_cast(configEntry), subDir, RelevantFileType::ConfigFile, root.first, subDir->name()); } } } @@ -288,8 +294,7 @@ void getFiles(PkgFileInfo &pkgFileInfo) if(entryName.endsWith(QLatin1String(".qm"))) { if(const auto *qmEntry = trDir->entry(entryName)) { if(qmEntry->isFile()) { - const auto *qmFile = static_cast(qmEntry); - pkgFileInfo.relevantFiles.emplace_back(qmFile, RelevantFileType::Translation, root.first); + pkgFileInfo.relevantFiles.emplace_back(static_cast(qmEntry), trDir, RelevantFileType::Translation, root.first); } } } @@ -375,11 +380,11 @@ void makeArchive(const list &pkgFiles, const QByteArray &pkgList, c mode = 0100644; break; } - if(relevantFile.symlinkTarget.isEmpty()) { + //if(relevantFile.symlinkTarget.isEmpty()) { targetArchive->writeFile(path, relevantFile.data, mode); - } else { - targetArchive->writeSymLink(path, relevantFile.symlinkTarget, QString(), QString(), mode); - } + //} else { + // targetArchive->writeSymLink(path, relevantFile.symlinkTarget, QString(), QString(), mode); + //} } } }