fixed symlinks
This commit is contained in:
parent
a48a6fd656
commit
355a25b172
|
@ -135,20 +135,26 @@ enum class RelevantFileArch
|
||||||
|
|
||||||
struct RelevantFile
|
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()),
|
name(file->name()),
|
||||||
data(file->data()),
|
|
||||||
fileType(type),
|
fileType(type),
|
||||||
arch(arch),
|
arch(arch),
|
||||||
subDir(subDir),
|
subDir(subDir)
|
||||||
symlinkTarget(file->symLinkTarget())
|
{
|
||||||
{}
|
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;
|
QString name;
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
RelevantFileType fileType;
|
RelevantFileType fileType;
|
||||||
RelevantFileArch arch;
|
RelevantFileArch arch;
|
||||||
QString subDir;
|
QString subDir;
|
||||||
QString symlinkTarget;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PkgFileInfo
|
struct PkgFileInfo
|
||||||
|
@ -173,7 +179,7 @@ void addEntries(PkgFileInfo &pkgFileInfo, RelevantFileType fileType, const KArch
|
||||||
if(entry->isDirectory()) {
|
if(entry->isDirectory()) {
|
||||||
addEntries(pkgFileInfo, fileType, static_cast<const KArchiveDirectory *>(entry), newPath);
|
addEntries(pkgFileInfo, fileType, static_cast<const KArchiveDirectory *>(entry), newPath);
|
||||||
} else if(entry->isFile()) {
|
} 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(entryName.endsWith(QLatin1String(".exe")) || entryName.endsWith(QLatin1String(".dll"))) {
|
||||||
if(const auto *entry = binDir->entry(entryName)) {
|
if(const auto *entry = binDir->entry(entryName)) {
|
||||||
if(entry->isFile()) {
|
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()) {
|
for(const auto &entryName : categoryDir->entries()) {
|
||||||
if(const auto *pluginEntry = categoryDir->entry(entryName)) {
|
if(const auto *pluginEntry = categoryDir->entry(entryName)) {
|
||||||
if(pluginEntry->isFile()) {
|
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(entryName.endsWith(QLatin1String(".qm"))) {
|
||||||
if(const auto *qmEntry = trDir->entry(entryName)) {
|
if(const auto *qmEntry = trDir->entry(entryName)) {
|
||||||
if(qmEntry->isFile()) {
|
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()) {
|
for(const auto &entryName : appDir->entries()) {
|
||||||
const auto *entry = appDir->entry(entryName);
|
const auto *entry = appDir->entry(entryName);
|
||||||
if(entry->isFile()) {
|
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 {
|
} else {
|
||||||
const auto subDir = static_cast<const KArchiveDirectory *>(entry);
|
const auto subDir = static_cast<const KArchiveDirectory *>(entry);
|
||||||
if(entryName == QLatin1String("translations")) {
|
if(entryName == QLatin1String("translations")) {
|
||||||
|
@ -264,7 +270,7 @@ void getFiles(PkgFileInfo &pkgFileInfo)
|
||||||
if(entryName.endsWith(QLatin1String(".qm"))) {
|
if(entryName.endsWith(QLatin1String(".qm"))) {
|
||||||
if(const auto *qmEntry = subDir->entry(entryName)) {
|
if(const auto *qmEntry = subDir->entry(entryName)) {
|
||||||
if(qmEntry->isFile()) {
|
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()) {
|
for(const auto &entryName : subDir->entries()) {
|
||||||
if(const auto *configEntry = subDir->entry(entryName)) {
|
if(const auto *configEntry = subDir->entry(entryName)) {
|
||||||
if(configEntry->isFile()) {
|
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(entryName.endsWith(QLatin1String(".qm"))) {
|
||||||
if(const auto *qmEntry = trDir->entry(entryName)) {
|
if(const auto *qmEntry = trDir->entry(entryName)) {
|
||||||
if(qmEntry->isFile()) {
|
if(qmEntry->isFile()) {
|
||||||
const auto *qmFile = static_cast<const KArchiveFile *>(qmEntry);
|
pkgFileInfo.relevantFiles.emplace_back(static_cast<const KArchiveFile *>(qmEntry), trDir, RelevantFileType::Translation, root.first);
|
||||||
pkgFileInfo.relevantFiles.emplace_back(qmFile, RelevantFileType::Translation, root.first);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,11 +380,11 @@ void makeArchive(const list<PkgFileInfo> &pkgFiles, const QByteArray &pkgList, c
|
||||||
mode = 0100644;
|
mode = 0100644;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(relevantFile.symlinkTarget.isEmpty()) {
|
//if(relevantFile.symlinkTarget.isEmpty()) {
|
||||||
targetArchive->writeFile(path, relevantFile.data, mode);
|
targetArchive->writeFile(path, relevantFile.data, mode);
|
||||||
} else {
|
//} else {
|
||||||
targetArchive->writeSymLink(path, relevantFile.symlinkTarget, QString(), QString(), mode);
|
// targetArchive->writeSymLink(path, relevantFile.symlinkTarget, QString(), QString(), mode);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue