add setGameFolder, fixed build bug in Linux
This commit is contained in:
parent
d968e0bc0e
commit
4c06c6cd1e
2 changed files with 28 additions and 3 deletions
30
AppEnv.cpp
30
AppEnv.cpp
|
@ -45,7 +45,9 @@ QString AppEnv::getGameFolder(bool *ok)
|
|||
#ifdef GTA5SYNC_WIN
|
||||
_putenv(QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str());
|
||||
#else
|
||||
putenv(QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str());
|
||||
char* GTAV_FOLDER_char = QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str();
|
||||
putenv(GTAV_FOLDER_char);
|
||||
delete GTAV_FOLDER_char;
|
||||
#endif
|
||||
return dir.absolutePath();
|
||||
}
|
||||
|
@ -71,7 +73,9 @@ QString AppEnv::getGameFolder(bool *ok)
|
|||
#ifdef GTA5SYNC_WIN
|
||||
_putenv(QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str());
|
||||
#else
|
||||
putenv(QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str());
|
||||
char* GTAV_FOLDER_char = QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str();
|
||||
putenv(GTAV_FOLDER_char);
|
||||
delete GTAV_FOLDER_char;
|
||||
#endif
|
||||
return dir.absolutePath();
|
||||
}
|
||||
|
@ -84,7 +88,9 @@ QString AppEnv::getGameFolder(bool *ok)
|
|||
#ifdef GTA5SYNC_WIN
|
||||
_putenv(QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str());
|
||||
#else
|
||||
putenv(QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str());
|
||||
char* GTAV_FOLDER_char = QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str();
|
||||
putenv(GTAV_FOLDER_char);
|
||||
delete GTAV_FOLDER_char;
|
||||
#endif
|
||||
return dir.absolutePath();
|
||||
}
|
||||
|
@ -93,3 +99,21 @@ QString AppEnv::getGameFolder(bool *ok)
|
|||
ok = &retok;
|
||||
return "";
|
||||
}
|
||||
|
||||
bool AppEnv::setGameFolder(QString gameFolder)
|
||||
{
|
||||
QDir dir;
|
||||
dir.setPath(gameFolder);
|
||||
if (dir.exists())
|
||||
{
|
||||
#ifdef GTA5SYNC_WIN
|
||||
_putenv(QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str());
|
||||
#else
|
||||
char* GTAV_FOLDER_char = QString("GTAV_FOLDER=" + dir.absolutePath()).toStdString().c_str();
|
||||
putenv(GTAV_FOLDER_char);
|
||||
delete GTAV_FOLDER_char;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
1
AppEnv.h
1
AppEnv.h
|
@ -26,6 +26,7 @@ class AppEnv
|
|||
public:
|
||||
AppEnv();
|
||||
static QString getGameFolder(bool *ok = 0);
|
||||
static bool setGameFolder(QString gameFolder);
|
||||
};
|
||||
|
||||
#endif // APPENV_H
|
||||
|
|
Loading…
Reference in a new issue