Skip to content

Commit 9a8181e

Browse files
committed
fix creating symbolic link logic
1 parent e494122 commit 9a8181e

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

clean_nvim_lsp.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ rm -fr build
66
rm -fr CMakeCache.txt CMakeFiles Makefile cmake_install.cmake \
77
compile_commands.json TombRaiderLinuxLauncher \
88
.cache TombRaiderLinuxLauncher_autogen \
9-
TombRaiderLinuxLauncherTest_autogen CTestTestfile.cmake
9+
TombRaiderLinuxLauncherTest_autogen CTestTestfile.cmake \
10+
.gdb .gdbinit

src/FileManager.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <QByteArray>
2222
#include <QDataStream>
2323
#include "gameTree.hpp"
24+
#include "miniz.h"
25+
#include "miniz_zip.h"
2426

2527
bool FileManager::setUpCamp(const QString& levelDir, const QString& gameDir) {
2628
bool status = true;
@@ -212,6 +214,7 @@ int FileManager::checkFileInfo(const QString& file, bool lookGameDir) {
212214
}
213215

214216
bool FileManager::linkGameDir(const QString& levelDir, const QString& gameDir) {
217+
bool status = false;
215218
const QString levelPath = QString("%1%2")
216219
.arg(m_levelDir.absolutePath(), levelDir);
217220
const QString gamePath = QString("%1%2")
@@ -228,16 +231,17 @@ bool FileManager::linkGameDir(const QString& levelDir, const QString& gameDir) {
228231
QFile::remove(gamePath);
229232
if (QFile::link(levelPath, gamePath)) {
230233
qDebug() << "Symbolic link created successfully.";
231-
return 0;
234+
status = true;
232235
} else {
233236
qDebug() << "Failed to create symbolic link.";
234-
return 1;
237+
status = false;
235238
}
236239
} else {
237240
qDebug() << "Failed to create symbolic link.";
238-
return 1;
241+
status = false;
239242
}
240243
}
244+
return status;
241245
}
242246

243247
bool FileManager::makeRelativeLink(

src/FileManager.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#include <QDir>
2121
#include <QCryptographicHash>
2222
#include <QDebug>
23-
#include "miniz.h"
24-
#include "miniz_zip.h"
2523

2624
class FileManager : public QObject {
2725
Q_OBJECT

src/Model.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,20 @@ int Model::getItemState(int id) {
124124
}
125125

126126
bool Model::setLink(int id) {
127+
bool status = false;
127128
if (id < 0) {
128129
id = -id;
129130
const QString s = "/Original.TR" + QString::number(id);
130131
if (fileManager.checkDir(s, false ))
131-
return fileManager.linkGameDir(s, getGameDirectory(id));
132+
status = fileManager.linkGameDir(s, getGameDirectory(id));
132133
} else if (id > 0) {
133134
const QString s = "/"+QString::number(id) + ".TRLE";
134135
const int t = data.getType(id);
135136

136137
if (fileManager.checkDir(s, false ))
137-
return fileManager.linkGameDir(s, getGameDirectory(t));
138+
status = fileManager.linkGameDir(s, getGameDirectory(t));
138139
}
139-
return false;
140+
return status;
140141
}
141142

142143
void Model::setupGame(int id) {
@@ -187,7 +188,7 @@ bool Model::getGame(int id) {
187188

188189
if (fileManager.checkFile(zipData.name, false)) {
189190
qDebug() << "File exists:" << zipData.name;
190-
const QString& sum = fileManager.calculateMD5(zipData.name, false);
191+
const QString sum = fileManager.calculateMD5(zipData.name, false);
191192
if (sum != zipData.md5sum) {
192193
downloader.run();
193194
status = downloader.getStatus();
@@ -204,7 +205,19 @@ bool Model::getGame(int id) {
204205
status = downloader.getStatus();
205206
}
206207
if (status == 0) {
207-
fileManager.extractZip(zipData.name, QString::number(id)+".TRLE");
208+
/* when the problem about updateing sum is solved it should verify
209+
* the download md5sum can just change on trle so it should just
210+
* update it
211+
const QString sum = fileManager.calculateMD5(zipData.name, false);
212+
if (sum == zipData.md5sum) {
213+
const QString directory = QString::number(id)+".TRLE";
214+
fileManager.extractZip(zipData.name, directory);
215+
instructionManager.executeInstruction(id);
216+
return true;
217+
}
218+
*/
219+
const QString directory = QString::number(id)+".TRLE";
220+
fileManager.extractZip(zipData.name, directory);
208221
instructionManager.executeInstruction(id);
209222
return true;
210223
}

0 commit comments

Comments
 (0)