From 40012b1b46a96a104b81c7858c550af8cf0d377b Mon Sep 17 00:00:00 2001 From: Rafael Date: Thu, 27 Oct 2016 07:19:51 +0200 Subject: [PATCH] Prevent user to import a hidden Snapmatic twice --- ProfileInterface.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index ddc5e55..ce777b4 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -487,11 +487,21 @@ bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, QString { QFileInfo picFileInfo(picPath); QString picFileName = picFileInfo.fileName(); + QString adjustedFileName = picFileName; + if (adjustedFileName.right(7) == ".hidden") // for the hidden file system + { + adjustedFileName.remove(adjustedFileName.length() - 7, 7); + } if (picFileName.left(4) != "PGTA") { if (warn) QMessageBox::warning(this, tr("Import"), tr("Failed to import the Snapmatic picture, file not begin with PGTA")); return false; } + else if (QFile::exists(profileFolder + QDir::separator() + adjustedFileName) || QFile::exists(profileFolder + QDir::separator() + adjustedFileName + ".hidden")) + { + if (warn) QMessageBox::warning(this, tr("Import"), tr("Failed to import the Snapmatic picture, the picture is already in the game")); + return false; + } else if (QFile::copy(picPath, profileFolder + QDir::separator() + picFileName)) { picture->setPicFileName(profileFolder + QDir::separator() + picFileName);