switch from native environment value demand feature to qt demand feature

This commit is contained in:
Rafael 2016-04-20 12:50:48 +02:00
parent 9608ea88bf
commit 6ee9007442

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include "config.h" #include "config.h"
#include "AppEnv.h" #include "AppEnv.h"
#include "StringParser.h" #include "StringParser.h"
#include "StandardPaths.h" #include "StandardPaths.h"
#include <QDir> #include <QDir>
#include <QDebug> #include <QDebug>
#include <QtGlobal>
#include <QSettings> #include <QSettings>
#include <iostream> #include <iostream>
using namespace std; using namespace std;
@ -37,18 +37,14 @@ AppEnv::AppEnv()
QString AppEnv::getGameFolder(bool *ok) QString AppEnv::getGameFolder(bool *ok)
{ {
QDir dir; QDir dir;
QString GTAV_FOLDER(getenv("GTAV_FOLDER")); QString GTAV_FOLDER(qgetenv("GTAV_FOLDER"));
if (GTAV_FOLDER != "") if (GTAV_FOLDER != "")
{ {
dir.setPath(GTAV_FOLDER); dir.setPath(GTAV_FOLDER);
if (dir.exists()) if (dir.exists())
{ {
*ok = true; *ok = true;
#ifdef GTA5SYNC_WIN qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
_putenv(QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str());
#else
setenv("GTAV_FOLDER", dir.absolutePath().toStdString().c_str(), 1);
#endif
return dir.absolutePath(); return dir.absolutePath();
} }
} }
@ -69,11 +65,7 @@ QString AppEnv::getGameFolder(bool *ok)
if (dir.exists()) if (dir.exists())
{ {
*ok = true; *ok = true;
#ifdef GTA5SYNC_WIN qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
_putenv(QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str());
#else
setenv("GTAV_FOLDER", dir.absolutePath().toStdString().c_str(), 1);
#endif
return dir.absolutePath(); return dir.absolutePath();
} }
@ -81,11 +73,7 @@ QString AppEnv::getGameFolder(bool *ok)
if (dir.exists()) if (dir.exists())
{ {
*ok = true; *ok = true;
#ifdef GTA5SYNC_WIN qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
_putenv(QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str());
#else
setenv("GTAV_FOLDER", dir.absolutePath().toStdString().c_str(), 1);
#endif
return dir.absolutePath(); return dir.absolutePath();
} }
@ -99,11 +87,7 @@ bool AppEnv::setGameFolder(QString gameFolder)
dir.setPath(gameFolder); dir.setPath(gameFolder);
if (dir.exists()) if (dir.exists())
{ {
#ifdef GTA5SYNC_WIN qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
_putenv(QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str());
#else
setenv("GTAV_FOLDER", dir.absolutePath().toStdString().c_str(), 1);
#endif
return true; return true;
} }
return false; return false;