mirror of
https://github.com/glest/glest-source.git
synced 2025-08-31 03:39:54 +02:00
added a check for data and user data paths being the same
This commit is contained in:
@@ -251,6 +251,8 @@ bool isKeyDown(int virtualKey);
|
||||
//bool isKeyDown(SDLKey key);
|
||||
string getCommandLine();
|
||||
|
||||
string getUserHome();
|
||||
|
||||
#define SPACES " "
|
||||
|
||||
inline string trim_at_delim (const string & s, const string &t) {
|
||||
|
@@ -59,7 +59,7 @@ public:
|
||||
// =====================================================
|
||||
// Misc
|
||||
// =====================================================
|
||||
void message(string message,bool isNonGraphicalModeEnabled);
|
||||
void message(string message,bool isNonGraphicalModeEnabled, string writepath);
|
||||
void exceptionMessage(const exception &excp);
|
||||
|
||||
string getCommandLine();
|
||||
@@ -102,7 +102,7 @@ std::string utf8_encode(const std::wstring &wstr);
|
||||
std::wstring utf8_decode(const std::string &str);
|
||||
std::string getRegKey(const std::string& location, const std::string& name);
|
||||
|
||||
void message(string message, bool isNonGraphicalModeEnabled);
|
||||
void message(string message, bool isNonGraphicalModeEnabled,string writepath);
|
||||
void exceptionMessage(const exception &excp);
|
||||
string getCommandLine();
|
||||
void init_win32();
|
||||
|
@@ -65,12 +65,20 @@
|
||||
#include "platform_util.h"
|
||||
#include "utf8.h"
|
||||
#include "byte_order.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
|
||||
using namespace Shared::Platform;
|
||||
using namespace Shared::Util;
|
||||
using namespace std;
|
||||
@@ -2389,5 +2397,19 @@ void ValueCheckerVault::checkItemInVault(const void *ptr,int value) const {
|
||||
|
||||
}
|
||||
|
||||
string getUserHome() {
|
||||
string home_folder = "";
|
||||
const char *homedir = getenv("HOME");
|
||||
if (!homedir) {
|
||||
#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
|
||||
struct passwd *pw = getpwuid(getuid());
|
||||
homedir = pw->pw_dir;
|
||||
#else
|
||||
homedir = "";
|
||||
#endif
|
||||
}
|
||||
home_folder = homedir;
|
||||
return home_folder;
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
@@ -44,7 +44,14 @@ const char * getDialogCommand() {
|
||||
}
|
||||
*/
|
||||
|
||||
FILE *file = popen("which gdialog","r");
|
||||
FILE *file = popen("which zenity","r");
|
||||
//printf("File #1 [%p]\n",file);
|
||||
if (file != NULL) {
|
||||
pclose(file);
|
||||
return "zenity";
|
||||
}
|
||||
|
||||
file = popen("which gdialog","r");
|
||||
//printf("File #1 [%p]\n",file);
|
||||
if (file != NULL) {
|
||||
pclose(file);
|
||||
@@ -60,14 +67,25 @@ const char * getDialogCommand() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool showMessage(std::string warning) {
|
||||
bool showMessage(std::string warning,string writepath) {
|
||||
bool guiMessage = false;
|
||||
const char * dialogCommand = getDialogCommand();
|
||||
if (dialogCommand) {
|
||||
std::string command = dialogCommand;
|
||||
command += " --title \"Error\" --msgbox \"`printf \"" + warning.erase(4096,std::string::npos) + "\"`\"";
|
||||
|
||||
//printf("\n\n\nzenity command [%s]\n\n\n",command.c_str());
|
||||
string text_file = writepath + "/mg_dialog_text.txt";
|
||||
{
|
||||
FILE *fp = fopen(text_file.c_str(),"wt");
|
||||
if (fp != NULL) {
|
||||
fputs(warning.c_str(),fp);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
//command += " --title \"Error\" --msgbox \"`printf \"" + warning + "\"`\"";
|
||||
command += " --title \"Error\" --text-info --filename=" + text_file;
|
||||
|
||||
printf("\n\n\nzenity command [%s]\n\n\n",command.c_str());
|
||||
|
||||
FILE *fp = popen(command.c_str(),"r");
|
||||
if (fp != 0)
|
||||
@@ -78,7 +96,7 @@ bool showMessage(std::string warning) {
|
||||
return guiMessage;
|
||||
}
|
||||
|
||||
void message(string message, bool isNonGraphicalModeEnabled) {
|
||||
void message(string message, bool isNonGraphicalModeEnabled,string writepath) {
|
||||
std::cerr << "\n\n\n";
|
||||
std::cerr << "******************************************************\n";
|
||||
std::cerr << " " << message << "\n";
|
||||
@@ -86,7 +104,7 @@ void message(string message, bool isNonGraphicalModeEnabled) {
|
||||
std::cerr << "\n\n\n";
|
||||
|
||||
if(isNonGraphicalModeEnabled == false) {
|
||||
showMessage(message);
|
||||
showMessage(message,writepath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -341,7 +341,7 @@ megaglest_runtime_error::megaglest_runtime_error(const string& __arg,bool noStac
|
||||
// assert(dispChangeErr==DISP_CHANGE_SUCCESSFUL);
|
||||
//}
|
||||
|
||||
void message(string message, bool isNonGraphicalModeEnabled) {
|
||||
void message(string message, bool isNonGraphicalModeEnabled,string writepath) {
|
||||
std::cerr << "******************************************************\n";
|
||||
std::cerr << " " << message << "\n";
|
||||
std::cerr << "******************************************************\n";
|
||||
|
@@ -28,12 +28,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include "utf8.h"
|
||||
#include "font.h"
|
||||
#include "string_utils.h"
|
||||
@@ -177,21 +171,6 @@ void Properties::load(const string &path, bool clearCurrentProperties) {
|
||||
#endif
|
||||
}
|
||||
|
||||
string getUserHomeFromGLIBC() {
|
||||
string home_folder = "";
|
||||
const char *homedir = getenv("HOME");
|
||||
if (!homedir) {
|
||||
#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
|
||||
struct passwd *pw = getpwuid(getuid());
|
||||
homedir = pw->pw_dir;
|
||||
#else
|
||||
homedir = "";
|
||||
#endif
|
||||
}
|
||||
home_folder = homedir;
|
||||
return home_folder;
|
||||
}
|
||||
|
||||
std::map<string,string> Properties::getTagReplacementValues(std::map<string,string> *mapExtraTagReplacementValues) {
|
||||
std::map<string,string> mapTagReplacementValues;
|
||||
|
||||
@@ -202,7 +181,7 @@ std::map<string,string> Properties::getTagReplacementValues(std::map<string,stri
|
||||
#ifdef WIN32
|
||||
const char *homeDir = getenv("USERPROFILE");
|
||||
#else
|
||||
string home = getUserHomeFromGLIBC();
|
||||
string home = getUserHome();
|
||||
const char *homeDir = home.c_str();
|
||||
#endif
|
||||
|
||||
@@ -304,7 +283,7 @@ bool Properties::applyTagsToValue(string &value, const std::map<string,string> *
|
||||
#ifdef WIN32
|
||||
const char *homeDir = getenv("USERPROFILE");
|
||||
#else
|
||||
string home = getUserHomeFromGLIBC();
|
||||
string home = getUserHome();
|
||||
const char *homeDir = home.c_str();
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user