added a check for data and user data paths being the same

This commit is contained in:
Mark Vejvoda
2013-11-06 00:31:36 +00:00
parent e689ac8bff
commit 70421d1b3d
7 changed files with 70 additions and 39 deletions

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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";