|
|
@ -29,6 +29,10 @@ Wizard::UnshieldWorker::UnshieldWorker(QObject *parent) :
|
|
|
|
mInstallMorrowind = false;
|
|
|
|
mInstallMorrowind = false;
|
|
|
|
mInstallTribunal = false;
|
|
|
|
mInstallTribunal = false;
|
|
|
|
mInstallBloodmoon = false;
|
|
|
|
mInstallBloodmoon = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mMorrowindDone = false;
|
|
|
|
|
|
|
|
mTribunalDone = false;
|
|
|
|
|
|
|
|
mBloodmoonDone = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Wizard::UnshieldWorker::~UnshieldWorker()
|
|
|
|
Wizard::UnshieldWorker::~UnshieldWorker()
|
|
|
@ -119,25 +123,30 @@ bool Wizard::UnshieldWorker::removeDirectory(const QString &dirName)
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::moveFile(const QString &source, const QString &destination)
|
|
|
|
bool Wizard::UnshieldWorker::copyFile(const QString &source, const QString &destination, bool keepSource)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QDir dir;
|
|
|
|
QDir dir;
|
|
|
|
QFile file;
|
|
|
|
QFile file;
|
|
|
|
|
|
|
|
|
|
|
|
if (dir.rename(source, destination)) {
|
|
|
|
QFileInfo info(destination);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (info.exists())
|
|
|
|
|
|
|
|
dir.remove(info.absoluteFilePath());
|
|
|
|
|
|
|
|
|
|
|
|
if (file.copy(source, destination)) {
|
|
|
|
if (file.copy(source, destination)) {
|
|
|
|
|
|
|
|
if (!keepSource) {
|
|
|
|
return file.remove(source);
|
|
|
|
return file.remove(source);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
qDebug() << "copy failed! " << file.errorString();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
qDebug() << "copy failed! " << file.errorString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::moveDirectory(const QString &source, const QString &destination)
|
|
|
|
bool Wizard::UnshieldWorker::copyDirectory(const QString &source, const QString &destination, bool keepSource)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QDir sourceDir(source);
|
|
|
|
QDir sourceDir(source);
|
|
|
|
QDir destDir(destination);
|
|
|
|
QDir destDir(destination);
|
|
|
@ -170,127 +179,217 @@ bool Wizard::UnshieldWorker::moveDirectory(const QString &source, const QString
|
|
|
|
|
|
|
|
|
|
|
|
result = moveFile(info.absoluteFilePath(), destDir.absolutePath() + relativePath);
|
|
|
|
result = moveFile(info.absoluteFilePath(), destDir.absolutePath() + relativePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//if (!result)
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!keepSource)
|
|
|
|
return result && removeDirectory(sourceDir.absolutePath());
|
|
|
|
return result && removeDirectory(sourceDir.absolutePath());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::extract()
|
|
|
|
bool Wizard::UnshieldWorker::moveFile(const QString &source, const QString &destination)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
emit textChanged(QLatin1String("Starting installation"));
|
|
|
|
return copyFile(source, destination, false);
|
|
|
|
emit textChanged(QLatin1String("Installation target: ") + mPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QStringList components;
|
|
|
|
bool Wizard::UnshieldWorker::moveDirectory(const QString &source, const QString &destination)
|
|
|
|
if (mInstallMorrowind)
|
|
|
|
{
|
|
|
|
components << QLatin1String("Morrowind");
|
|
|
|
return copyDirectory(source, destination, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (mInstallTribunal)
|
|
|
|
void Wizard::UnshieldWorker::installDirectories(const QString &source)
|
|
|
|
components << QLatin1String("Tribunal");
|
|
|
|
{
|
|
|
|
|
|
|
|
QDir dir(source);
|
|
|
|
|
|
|
|
|
|
|
|
if (mInstallBloodmoon)
|
|
|
|
if (!dir.exists())
|
|
|
|
components << QLatin1String("Bloodmoon");
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
emit textChanged(QLatin1String("Components: ") + components.join(QLatin1String(", ")));
|
|
|
|
QStringList directories;
|
|
|
|
|
|
|
|
directories << QLatin1String("Fonts")
|
|
|
|
|
|
|
|
<< QLatin1String("Music")
|
|
|
|
|
|
|
|
<< QLatin1String("Sound")
|
|
|
|
|
|
|
|
<< QLatin1String("Splash")
|
|
|
|
|
|
|
|
<< QLatin1String("Video");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFileInfoList list(dir.entryInfoList(QDir::NoDotAndDotDot |
|
|
|
|
|
|
|
|
QDir::System | QDir::Hidden |
|
|
|
|
|
|
|
|
QDir::AllDirs));
|
|
|
|
|
|
|
|
foreach(QFileInfo info, list) {
|
|
|
|
|
|
|
|
if (info.isSymLink())
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
emit textChanged(QLatin1String("Updating Morrowind.ini: ") + mIniPath);
|
|
|
|
if (directories.contains(info.fileName())) {
|
|
|
|
|
|
|
|
qDebug() << "found " << info.fileName();
|
|
|
|
|
|
|
|
emit textChanged(tr("Extracting: %1 directory").arg(info.fileName()));
|
|
|
|
|
|
|
|
copyDirectory(info.absoluteFilePath(), mPath + QDir::separator() + info.fileName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//emit progressChanged(45);
|
|
|
|
void Wizard::UnshieldWorker::extract()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
emit textChanged(QLatin1String("Starting installation"));
|
|
|
|
|
|
|
|
emit textChanged(QLatin1String("Installation target: ") + mPath);
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
QString diskPath("/mnt/cdrom/");
|
|
|
|
// bfs::path outputDataFilesDir = mOutputPath;
|
|
|
|
QDir disk(diskPath);
|
|
|
|
// outputDataFilesDir /= "Data Files";
|
|
|
|
|
|
|
|
// bfs::path extractPath = mOutputPath;
|
|
|
|
|
|
|
|
// extractPath /= "extract-temp";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create temporary extract directory
|
|
|
|
// Create temporary extract directory
|
|
|
|
// TODO: Use QTemporaryDir in Qt 5.0
|
|
|
|
// TODO: Use QTemporaryDir in Qt 5.0
|
|
|
|
QString tempPath(mPath + QLatin1String("/extract-temp"));
|
|
|
|
QString tempPath(mPath + QDir::separator() + QLatin1String("extract-temp"));
|
|
|
|
QDir dir;
|
|
|
|
QDir temp;
|
|
|
|
dir.mkpath(tempPath);
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure the temporary folder is empty
|
|
|
|
|
|
|
|
removeDirectory(tempPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!temp.mkpath(tempPath)) {
|
|
|
|
|
|
|
|
qDebug() << "Can't make path";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
temp.setPath(tempPath);
|
|
|
|
|
|
|
|
disk.setPath(diskPath);
|
|
|
|
|
|
|
|
|
|
|
|
if (mInstallMorrowind)
|
|
|
|
if (mInstallMorrowind)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QString morrowindTempPath(tempPath + QLatin1String("/morrowind"));
|
|
|
|
emit textChanged(QLatin1String("Installing Morrowind\n"));
|
|
|
|
QString morrowindCab(QLatin1String("/mnt/cdrom/data1.hdr"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//extractCab(morrowindCab, morrowindTempPath);
|
|
|
|
if (!temp.mkdir(QLatin1String("morrowind"))) {
|
|
|
|
|
|
|
|
qDebug() << "Can't make dir";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!temp.cd(QLatin1String("morrowind"))) {
|
|
|
|
|
|
|
|
qDebug() << "Can't cd to dir";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!disk.exists(QLatin1String("data1.hdr"))) {
|
|
|
|
|
|
|
|
qDebug() << "No data found!";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Extract the installation files
|
|
|
|
|
|
|
|
extractCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), temp.absolutePath());
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Throw error;
|
|
|
|
// TODO: Throw error;
|
|
|
|
// Move the files from the temporary path to the destination folder
|
|
|
|
// Move the files from the temporary path to the destination folder
|
|
|
|
|
|
|
|
|
|
|
|
//qDebug() << "rename: " << morrowindTempPath << " to: " << mPath;
|
|
|
|
//qDebug() << "rename: " << morrowindTempPath << " to: " << mPath;
|
|
|
|
morrowindTempPath.append(QDir::separator() + QLatin1String("Data Files"));
|
|
|
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), mPath))
|
|
|
|
// if (!moveDirectory(morrowindTempPath, mPath))
|
|
|
|
qDebug() << "failed!";
|
|
|
|
// qDebug() << "failed!";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QDir sourceDir(QLatin1String("/mnt/cdrom/"));
|
|
|
|
// Install files outside of cab archives
|
|
|
|
QStringList directories;
|
|
|
|
qDebug() << temp.absolutePath() << disk.absolutePath();
|
|
|
|
directories << QLatin1String("Fonts")
|
|
|
|
installDirectories(disk.absolutePath());
|
|
|
|
<< QLatin1String("Music")
|
|
|
|
|
|
|
|
<< QLatin1String("Sound")
|
|
|
|
|
|
|
|
<< QLatin1String("Splash")
|
|
|
|
|
|
|
|
<< QLatin1String("Video");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFileInfoList list(sourceDir.entryInfoList(QDir::NoDotAndDotDot |
|
|
|
|
// Copy Morrowind configuration file
|
|
|
|
QDir::System | QDir::Hidden |
|
|
|
|
QString iniPath(temp.absoluteFilePath(QLatin1String("App Executables")));
|
|
|
|
QDir::AllDirs));
|
|
|
|
iniPath.append(QDir::separator() + QLatin1String("Morrowind.ini"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFileInfo info(iniPath);
|
|
|
|
|
|
|
|
|
|
|
|
foreach(QFileInfo info, list) {
|
|
|
|
qDebug() << info.absoluteFilePath() << mPath;
|
|
|
|
if (info.isSymLink())
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "not found " << info.fileName();
|
|
|
|
if (info.exists()) {
|
|
|
|
|
|
|
|
emit textChanged(tr("Extracting: Morrowind.ini"));
|
|
|
|
|
|
|
|
moveFile(info.absoluteFilePath(), mPath + QDir::separator() + QLatin1String("Morrowind.ini"));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
qDebug() << "Could not find ini file!";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (directories.contains(info.fileName()))
|
|
|
|
mMorrowindDone = true;
|
|
|
|
qDebug() << "found " << info.fileName();
|
|
|
|
|
|
|
|
// copyDirectory(info.absoluteFilePath(), mPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
temp.setPath(tempPath);
|
|
|
|
|
|
|
|
disk.setPath(diskPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mInstallTribunal)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
emit textChanged(QLatin1String("Installing Tribunal\n"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!temp.mkdir(QLatin1String("tribunal"))) {
|
|
|
|
|
|
|
|
qDebug() << "Can't make dir";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!temp.cd(QLatin1String("tribunal"))) {
|
|
|
|
|
|
|
|
qDebug() << "Can't cd to dir";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!disk.cd(QLatin1String("Tribunal")))
|
|
|
|
|
|
|
|
qDebug() << "Show file selector";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!disk.exists(QLatin1String("data1.hdr"))) {
|
|
|
|
|
|
|
|
qDebug() << "No data found!";
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Extract the installation files
|
|
|
|
|
|
|
|
extractCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), temp.absolutePath());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), mPath))
|
|
|
|
|
|
|
|
qDebug() << "failed!";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Install files outside of cab archives
|
|
|
|
|
|
|
|
installDirectories(disk.absolutePath());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mTribunalDone = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// if(!mMorrowindDone && mMorrowindPath.string().length() > 0)
|
|
|
|
temp.setPath(tempPath);
|
|
|
|
// {
|
|
|
|
disk.setPath(diskPath);
|
|
|
|
// mMorrowindDone = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (mInstallBloodmoon)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
emit textChanged(QLatin1String("Installing Bloodmoon\n"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!temp.mkdir(QLatin1String("bloodmoon"))) {
|
|
|
|
|
|
|
|
qDebug() << "Can't make dir";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// bfs::path mwExtractPath = extractPath / "morrowind";
|
|
|
|
if (!temp.cd(QLatin1String("bloodmoon"))) {
|
|
|
|
// extract_cab(mMorrowindPath, mwExtractPath, true);
|
|
|
|
qDebug() << "Can't cd to dir";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// bfs::path dFilesDir = findFile(mwExtractPath, "morrowind.esm").parent_path();
|
|
|
|
if (!disk.cd(QLatin1String("Bloodmoon")))
|
|
|
|
|
|
|
|
qDebug() << "Show file selector";
|
|
|
|
|
|
|
|
|
|
|
|
// installToPath(dFilesDir, outputDataFilesDir);
|
|
|
|
if (!disk.exists(QLatin1String("data1.hdr"))) {
|
|
|
|
|
|
|
|
qDebug() << "No data found!";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// install_dfiles_outside(mwExtractPath, outputDataFilesDir);
|
|
|
|
// Extract the installation files
|
|
|
|
|
|
|
|
extractCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), temp.absolutePath());
|
|
|
|
|
|
|
|
|
|
|
|
// // Videos are often kept uncompressed on the cd
|
|
|
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), mPath))
|
|
|
|
// bfs::path videosPath = findFile(mMorrowindPath.parent_path(), "video", false);
|
|
|
|
qDebug() << "failed!";
|
|
|
|
// if(videosPath.string() != "")
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// emit signalGUI(QString("Installing Videos..."));
|
|
|
|
|
|
|
|
// installToPath(videosPath, outputDataFilesDir / "Video", true);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bfs::path cdDFiles = findFile(mMorrowindPath.parent_path(), "data files", false);
|
|
|
|
// Install files outside of cab archives
|
|
|
|
// if(cdDFiles.string() != "")
|
|
|
|
installDirectories(disk.absolutePath());
|
|
|
|
// {
|
|
|
|
|
|
|
|
// emit signalGUI(QString("Installing Uncompressed Data files from CD..."));
|
|
|
|
|
|
|
|
// installToPath(cdDFiles, outputDataFilesDir, true);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mBloodmoonDone = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// bfs::rename(findFile(mwExtractPath, "morrowind.ini"), outputDataFilesDir / "Morrowind.ini");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// mTribunalDone = contains(outputDataFilesDir, "tribunal.esm");
|
|
|
|
int total = 0;
|
|
|
|
// mBloodmoonDone = contains(outputDataFilesDir, "bloodmoon.esm");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
if (mInstallMorrowind)
|
|
|
|
|
|
|
|
total = 100;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mInstallTribunal)
|
|
|
|
|
|
|
|
total = total + 100;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mInstallBloodmoon)
|
|
|
|
|
|
|
|
total = total + 100;
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
emit textChanged(tr("Installation finished!"));
|
|
|
|
|
|
|
|
emit progressChanged(total);
|
|
|
|
emit finished();
|
|
|
|
emit finished();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -322,17 +421,25 @@ bool Wizard::UnshieldWorker::extractFile(Unshield *unshield, const QString &outp
|
|
|
|
fileName.append(QString::fromLatin1(unshield_file_name(unshield, index)));
|
|
|
|
fileName.append(QString::fromLatin1(unshield_file_name(unshield, index)));
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate the percentage done
|
|
|
|
// Calculate the percentage done
|
|
|
|
int progress = qCeil(((float) counter / (float) unshield_file_count(unshield)) * 100);
|
|
|
|
int progress = qFloor(((float) counter / (float) unshield_file_count(unshield)) * 100);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mMorrowindDone)
|
|
|
|
|
|
|
|
progress = progress + 100;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mTribunalDone)
|
|
|
|
|
|
|
|
progress = progress + 100;
|
|
|
|
|
|
|
|
|
|
|
|
qDebug() << progress << counter << unshield_file_count(unshield);
|
|
|
|
qDebug() << progress << counter << unshield_file_count(unshield);
|
|
|
|
|
|
|
|
|
|
|
|
emit textChanged(QLatin1String("Extracting: ") + QString::fromLatin1(unshield_file_name(unshield, index)));
|
|
|
|
emit textChanged(tr("Extracting: %1").arg(QString::fromLatin1(unshield_file_name(unshield, index))));
|
|
|
|
emit progressChanged(progress);
|
|
|
|
emit progressChanged(progress);
|
|
|
|
|
|
|
|
|
|
|
|
success = unshield_file_save(unshield, index, fileName.toLatin1().constData());
|
|
|
|
success = unshield_file_save(unshield, index, fileName.toLatin1().constData());
|
|
|
|
|
|
|
|
|
|
|
|
if (!success)
|
|
|
|
if (!success) {
|
|
|
|
|
|
|
|
emit error(tr("Failed to extract %1").arg(fileName));
|
|
|
|
dir.remove(fileName);
|
|
|
|
dir.remove(fileName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return success;
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
}
|
|
|
|