@@ -30,7 +30,7 @@ bool FileManager::setUpCamp(const QString& levelDir, const QString& gameDir) {
3030 return false ;
3131 }
3232 }
33- levelDir_m .setPath (levelDir);
33+ m_levelDir .setPath (levelDir);
3434
3535 QDir gameDirPath (gameDir);
3636 if (!gameDirPath.exists ()) {
@@ -39,15 +39,15 @@ bool FileManager::setUpCamp(const QString& levelDir, const QString& gameDir) {
3939 return false ;
4040 }
4141 }
42- gameDir_m .setPath (gameDir);
42+ m_gameDir .setPath (gameDir);
4343
4444 return true ;
4545}
4646
4747const QString FileManager::calculateMD5 (const QString& file, bool lookGameDir) {
4848 const QString& path = lookGameDir ?
49- gameDir_m .absolutePath () + QDir::separator ()+file :
50- levelDir_m .absolutePath () + QDir::separator ()+file;
49+ m_gameDir .absolutePath () + QDir::separator ()+file :
50+ m_levelDir .absolutePath () + QDir::separator ()+file;
5151
5252 QFileInfo fileInfo (path);
5353
@@ -79,10 +79,10 @@ bool FileManager::extractZip(
7979 const QString& zipFilename,
8080 const QString& outputFolder) {
8181 const QString& zipPath =
82- levelDir_m .absolutePath () + QDir::separator () + zipFilename;
82+ m_levelDir .absolutePath () + QDir::separator () + zipFilename;
8383
8484 const QString& outputPath =
85- levelDir_m .absolutePath () + QDir::separator () + outputFolder;
85+ m_levelDir .absolutePath () + QDir::separator () + outputFolder;
8686
8787 qDebug () << " Unzipping file" << zipFilename << " to" << outputPath;
8888
@@ -173,9 +173,9 @@ bool FileManager::extractZip(
173173bool FileManager::checkDir (const QString& file, bool lookGameDir ) {
174174 QString path;
175175 if (!lookGameDir) {
176- path = levelDir_m .absolutePath () + QDir::separator () + file;
176+ path = m_levelDir .absolutePath () + QDir::separator () + file;
177177 } else {
178- path = gameDir_m .absolutePath () + QDir::separator () + file;
178+ path = m_gameDir .absolutePath () + QDir::separator () + file;
179179 }
180180 QDir directory (path);
181181 return directory.exists ();
@@ -184,18 +184,18 @@ bool FileManager::checkDir(const QString& file, bool lookGameDir ) {
184184bool FileManager::checkFile (const QString& file, bool lookGameDir ) {
185185 QString path;
186186 if (!lookGameDir) {
187- path = levelDir_m .absolutePath () + QDir::separator () + file;
187+ path = m_levelDir .absolutePath () + QDir::separator () + file;
188188 } else {
189- path = gameDir_m .absolutePath () + QDir::separator () + file;
189+ path = m_gameDir .absolutePath () + QDir::separator () + file;
190190 }
191191 QFile fFile (path);
192192 return fFile .exists ();
193193}
194194
195195int FileManager::checkFileInfo (const QString& file, bool lookGameDir) {
196196 const QString& path = lookGameDir ?
197- gameDir_m .absolutePath () + QDir::separator ()+file :
198- levelDir_m .absolutePath () + QDir::separator ()+file;
197+ m_gameDir .absolutePath () + QDir::separator ()+file :
198+ m_levelDir .absolutePath () + QDir::separator ()+file;
199199
200200 QFileInfo fileInfo (path);
201201 if (fileInfo.isDir ()) {
@@ -215,8 +215,8 @@ int FileManager::checkFileInfo(const QString& file, bool lookGameDir) {
215215}
216216
217217bool FileManager::linkGameDir (const QString& levelDir, const QString& gameDir) {
218- const QString& l = levelDir_m .absolutePath () + levelDir;
219- const QString& g = gameDir_m .absolutePath () + gameDir;
218+ const QString& l = m_levelDir .absolutePath () + levelDir;
219+ const QString& g = m_gameDir .absolutePath () + gameDir;
220220
221221 test (l);
222222
@@ -245,7 +245,7 @@ bool FileManager::makeRelativeLink(
245245 const QString& levelDir,
246246 const QString& from,
247247 const QString& to) {
248- const QString& l = levelDir_m .absolutePath () + levelDir;
248+ const QString& l = m_levelDir .absolutePath () + levelDir;
249249 const QString& f = l + from;
250250 const QString& t = l + to;
251251
@@ -270,67 +270,74 @@ bool FileManager::makeRelativeLink(
270270 }
271271}
272272
273- int FileManager::removeFileOrDirectory (const QString &file, bool lookGameDir) {
274- const QString& path = lookGameDir ?
275- gameDir_m.absolutePath () + QDir::separator ()+file :
276- levelDir_m.absolutePath () + QDir::separator ()+file;
273+ qint64 FileManager::removeFileOrDirectory (
274+ const QString &file,
275+ bool lookGameDir) {
276+ qint64 status = 0 ;
277+ const QString& sep = QDir::separator ();
278+ const QString& gamePath = m_gameDir.absolutePath () + sep + file;
279+ const QString& levelPath = m_levelDir.absolutePath () + sep + file;
280+ const QString& path = lookGameDir ? gamePath : levelPath;
277281
278282 QDir dir (path);
279283 if (dir.exists ()) {
280284 // Remove directory and its contents
281285 if (dir.removeRecursively ()) {
282286 qDebug () << " Directory removed successfully:" << path;
283- return 0 ;
287+ status = 0 ;
284288 } else {
285289 qWarning () << " Failed to remove directory:" << path;
286- return 1 ;
290+ status = 1 ;
287291 }
288292 } else {
289- QFile file (path);
293+ QFile f (path);
290294 // Check if the file exists before attempting to remove it
291- if (file .exists ()) {
292- if (file .remove ()) {
295+ if (f .exists ()) {
296+ if (f .remove ()) {
293297 qDebug () << " File removed successfully:" << path;
294- return 0 ;
298+ status = 0 ;
295299 } else {
296300 qWarning () << " Failed to remove file:" << path;
297- return 1 ;
301+ status = 1 ;
298302 }
299303 } else {
300304 qDebug () << " File or directory does not exist:" << path;
301- return 2 ;
305+ status = 2 ;
302306 }
303307 }
308+ return status;
304309}
305310
306311int FileManager::createDirectory (const QString &file, bool gameDir) {
312+ qint64 status = 0 ;
307313 const QString& sep = QDir::separator ();
308- const QString& g = gameDir_m .absolutePath () + sep + file;
309- const QString& l = levelDir_m .absolutePath () + sep + file;
310- const QString& path = gameDir ? g : l ;
314+ const QString& gamePath = m_gameDir .absolutePath () + sep + file;
315+ const QString& levelPath = m_levelDir .absolutePath () + sep + file;
316+ const QString& path = gameDir ? gamePath : levelPath ;
311317
312318 // Create the directory if it doesn't exist
313319 if (!QDir (path).exists ()) {
314320 if (QDir ().mkpath (path)) {
315321 qDebug () << " Directory created successfully." ;
316- return 0 ;
322+ status = 0 ;
317323 } else {
318324 qDebug () << " Error creating directory." ;
319- return 1 ;
325+ status = 1 ;
320326 }
321327 } else {
322328 qDebug () << " Directory already exists." ;
323- return 0 ;
329+ status = 0 ;
324330 }
331+ return status;
325332}
326333
327334int FileManager::copyFile (
328335 const QString &gameFile,
329336 const QString &levelFile,
330337 bool fromGameDir) {
331338
332- const QString& gamePath = gameDir_m .absolutePath () + gameFile;
333- const QString& levelPath = levelDir_m .absolutePath () + levelFile;
339+ const QString& gamePath = m_gameDir .absolutePath () + gameFile;
340+ const QString& levelPath = m_levelDir .absolutePath () + levelFile;
334341
335342 const QString& g = fromGameDir ? gamePath : levelPath;
336343 const QString& l = fromGameDir ? levelPath : gamePath;
@@ -364,7 +371,7 @@ int FileManager::copyFile(
364371int FileManager::cleanWorkingDir (const QString &levelDir) {
365372 const QString sep = QDir::separator ();
366373 const QString& directoryPath =
367- levelDir_m .absolutePath () + sep + levelDir;
374+ m_levelDir .absolutePath () + sep + levelDir;
368375
369376 QDir directory (directoryPath);
370377 if (directory.exists ()) {
@@ -381,7 +388,7 @@ int FileManager::cleanWorkingDir(const QString &levelDir) {
381388}
382389
383390bool FileManager::backupGameDir (const QString &gameDir) {
384- const QString& source = gameDir_m .absolutePath () + gameDir.chopped (1 );
391+ const QString& source = m_gameDir .absolutePath () + gameDir.chopped (1 );
385392 const QString& des = source + " .old" ;
386393 QDir directory;
387394 if (directory.rename (source, des)) {
@@ -400,10 +407,10 @@ bool FileManager::moveFilesToDirectory(
400407 const QString& sep = QDir::separator ();
401408
402409 const QString& directoryFromPath =
403- levelDir_m .absolutePath () + sep + fromLevelDirectory;
410+ m_levelDir .absolutePath () + sep + fromLevelDirectory;
404411
405412 const QString& directoryToPath =
406- levelDir_m .absolutePath () + sep + toLevelDirectory;
413+ m_levelDir .absolutePath () + sep + toLevelDirectory;
407414
408415 QDir dir (directoryFromPath);
409416
@@ -430,7 +437,7 @@ bool FileManager::moveFilesToParentDirectory(
430437 int levelsUp) {
431438
432439 const QString& sep = QDir::separator ();
433- QDir levelDirectoryFullPath (levelDir_m .absolutePath () + sep +
440+ QDir levelDirectoryFullPath (m_levelDir .absolutePath () + sep +
434441 levelDirectory);
435442
436443 if (!levelDirectoryFullPath.exists ()) {
0 commit comments