Skip to content

Commit

Permalink
fix creating symbolic link logic
Browse files Browse the repository at this point in the history
  • Loading branch information
noisecode3 committed Dec 22, 2024
1 parent e494122 commit 9a8181e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
3 changes: 2 additions & 1 deletion clean_nvim_lsp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ rm -fr build
rm -fr CMakeCache.txt CMakeFiles Makefile cmake_install.cmake \
compile_commands.json TombRaiderLinuxLauncher \
.cache TombRaiderLinuxLauncher_autogen \
TombRaiderLinuxLauncherTest_autogen CTestTestfile.cmake
TombRaiderLinuxLauncherTest_autogen CTestTestfile.cmake \
.gdb .gdbinit
10 changes: 7 additions & 3 deletions src/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <QByteArray>
#include <QDataStream>
#include "gameTree.hpp"
#include "miniz.h"
#include "miniz_zip.h"

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

bool FileManager::linkGameDir(const QString& levelDir, const QString& gameDir) {
bool status = false;
const QString levelPath = QString("%1%2")
.arg(m_levelDir.absolutePath(), levelDir);
const QString gamePath = QString("%1%2")
Expand All @@ -228,16 +231,17 @@ bool FileManager::linkGameDir(const QString& levelDir, const QString& gameDir) {
QFile::remove(gamePath);
if (QFile::link(levelPath, gamePath)) {
qDebug() << "Symbolic link created successfully.";
return 0;
status = true;
} else {
qDebug() << "Failed to create symbolic link.";
return 1;
status = false;
}
} else {
qDebug() << "Failed to create symbolic link.";
return 1;
status = false;
}
}
return status;
}

bool FileManager::makeRelativeLink(
Expand Down
2 changes: 0 additions & 2 deletions src/FileManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include <QDir>
#include <QCryptographicHash>
#include <QDebug>
#include "miniz.h"
#include "miniz_zip.h"

class FileManager : public QObject {
Q_OBJECT
Expand Down
23 changes: 18 additions & 5 deletions src/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,20 @@ int Model::getItemState(int id) {
}

bool Model::setLink(int id) {
bool status = false;
if (id < 0) {
id = -id;
const QString s = "/Original.TR" + QString::number(id);
if (fileManager.checkDir(s, false ))
return fileManager.linkGameDir(s, getGameDirectory(id));
status = fileManager.linkGameDir(s, getGameDirectory(id));
} else if (id > 0) {
const QString s = "/"+QString::number(id) + ".TRLE";
const int t = data.getType(id);

if (fileManager.checkDir(s, false ))
return fileManager.linkGameDir(s, getGameDirectory(t));
status = fileManager.linkGameDir(s, getGameDirectory(t));
}
return false;
return status;
}

void Model::setupGame(int id) {
Expand Down Expand Up @@ -187,7 +188,7 @@ bool Model::getGame(int id) {

if (fileManager.checkFile(zipData.name, false)) {
qDebug() << "File exists:" << zipData.name;
const QString& sum = fileManager.calculateMD5(zipData.name, false);
const QString sum = fileManager.calculateMD5(zipData.name, false);
if (sum != zipData.md5sum) {
downloader.run();
status = downloader.getStatus();
Expand All @@ -204,7 +205,19 @@ bool Model::getGame(int id) {
status = downloader.getStatus();
}
if (status == 0) {
fileManager.extractZip(zipData.name, QString::number(id)+".TRLE");
/* when the problem about updateing sum is solved it should verify
* the download md5sum can just change on trle so it should just
* update it
const QString sum = fileManager.calculateMD5(zipData.name, false);
if (sum == zipData.md5sum) {
const QString directory = QString::number(id)+".TRLE";
fileManager.extractZip(zipData.name, directory);
instructionManager.executeInstruction(id);
return true;
}
*/
const QString directory = QString::number(id)+".TRLE";
fileManager.extractZip(zipData.name, directory);
instructionManager.executeInstruction(id);
return true;
}
Expand Down

0 comments on commit 9a8181e

Please sign in to comment.