fixed symlinks
This commit is contained in:
parent
a48a6fd656
commit
355a25b172
|
@ -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<const KArchiveFile *>(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<const KArchiveDirectory *>(entry), newPath);
|
||||
} else if(entry->isFile()) {
|
||||
pkgFileInfo.relevantFiles.emplace_back(static_cast<const KArchiveFile *>(entry), fileType, RelevantFileArch::Any, newPath);
|
||||
pkgFileInfo.relevantFiles.emplace_back(static_cast<const KArchiveFile *>(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<const KArchiveFile *>(entry), RelevantFileType::Binary, root.first);
|
||||
pkgFileInfo.relevantFiles.emplace_back(static_cast<const KArchiveFile *>(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<const KArchiveFile *>(pluginEntry), RelevantFileType::QtPlugin, root.first, categoryDir->name());
|
||||
pkgFileInfo.relevantFiles.emplace_back(static_cast<const KArchiveFile *>(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<const KArchiveFile *>(qmEntry), RelevantFileType::QtTranslation, root.first);
|
||||
pkgFileInfo.relevantFiles.emplace_back(static_cast<const KArchiveFile *>(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<const KArchiveFile *>(entry), RelevantFileType::ConfigFile, root.first);
|
||||
pkgFileInfo.relevantFiles.emplace_back(static_cast<const KArchiveFile *>(entry), appDir, RelevantFileType::ConfigFile, root.first);
|
||||
} else {
|
||||
const auto subDir = static_cast<const KArchiveDirectory *>(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<const KArchiveFile *>(qmEntry), RelevantFileType::Translation, root.first);
|
||||
pkgFileInfo.relevantFiles.emplace_back(static_cast<const KArchiveFile *>(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<const KArchiveFile *>(configEntry), RelevantFileType::ConfigFile, root.first, subDir->name());
|
||||
pkgFileInfo.relevantFiles.emplace_back(static_cast<const KArchiveFile *>(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<const KArchiveFile *>(qmEntry);
|
||||
pkgFileInfo.relevantFiles.emplace_back(qmFile, RelevantFileType::Translation, root.first);
|
||||
pkgFileInfo.relevantFiles.emplace_back(static_cast<const KArchiveFile *>(qmEntry), trDir, RelevantFileType::Translation, root.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -375,11 +380,11 @@ void makeArchive(const list<PkgFileInfo> &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);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue