}
#endif
+#include <string>
+
void Ui_MainWindow::OnMainWindowClosed(void)
{
// notify power off
hRunEmu->quit();
hRunEmu->wait();
delete hRunEmu;
+#if 0
save_config(create_local_path(_T("%s.ini"), _T(CONFIG_NAME)));
+#else
+ {
+ char tmps[128];
+ std::string localstr;
+ snprintf(tmps, sizeof(tmps), _T("%s.ini"), _T(CONFIG_NAME));
+ localstr = tmps;
+ localstr = cpp_confdir + localstr;
+ save_config(localstr.c_str());
+ }
+#endif
}
#if defined(USE_JOYSTICK)
if(hRunJoy != NULL) {
extern _TCHAR* DLL_PREFIX_I get_parent_dir(_TCHAR* file);
extern void get_short_filename(_TCHAR *dst, _TCHAR *file, int maxlen);
+#if defined(Q_OS_CYGWIN)
+#include <sys/stat.h>
+#endif
+static void my_util_mkdir(std::string n)
+{
+#if !defined(Q_OS_CYGWIN)
+ QDir dir = QDir::current();
+ dir.mkdir( QString::fromStdString(n));
+#else
+ struct stat st;
+ if(stat(n.c_str(), &st) != 0) {
+ _mkdir(n.c_str()); // Not found
+ }
+#endif
+}
+
static void setup_logs(void)
{
std::string delim;
cpp_homedir = ".";
#endif
cpp_homedir = cpp_homedir + delim;
-#ifdef _WINDOWS
- cpp_confdir = cpp_homedir + my_procname + delim;
-#else
- cpp_confdir = cpp_homedir + ".config" + delim + my_procname + delim;
+#ifndef _WINDOWS
+ cpp_confdir = cpp_homedir + ".config" + delim;
+ my_util_mkdir(cpp_confdir);
#endif
+
+ cpp_confdir = cpp_confdir + "CommonSourceCodeProject" + delim;
+ my_util_mkdir(cpp_confdir);
-#if !defined(Q_OS_CYGWIN)
- {
- QDir dir;
- dir.mkdir( QString::fromStdString(cpp_confdir));
- }
-#endif
+ cpp_confdir = cpp_confdir + delim + my_procname + delim;
+ my_util_mkdir(cpp_confdir);
//AG_MkPath(cpp_confdir.c_str());
/* Gettext */
#ifndef RSSDIR
std::string cfgstr(CONFIG_NAME);
setup_logs();
cpp_homedir.copy(homedir, PATH_MAX - 1, 0);
-
+#if 0
load_config(create_local_path(_T("%s.ini"), _T(CONFIG_NAME)));
+#else
+ {
+ char tmps[128];
+ std::string localstr;
+ snprintf(tmps, sizeof(tmps), _T("%s.ini"), _T(CONFIG_NAME));
+ localstr = tmps;
+ localstr = cpp_confdir + localstr;
+ load_config(localstr.c_str());
+ }
+#endif
+
emustr = emustr + cfgstr;
extern DLL_PREFIX_I std::string my_procname;
//extern DLL_PREFIX_I std::string sRssDir;
-#if 0
-void get_long_full_path_name(_TCHAR* src, _TCHAR* dst)
-{
- QString r_path;
- QString delim;
- QString ss;
- //const char *s;
- QDir mdir;
- if(src == NULL) {
- if(dst != NULL) dst[0] = '\0';
- return;
- }
-#ifdef _WINDOWS
- delim = "\\";
-#else
- delim = "/";
-#endif
- ss = "";
- if(cpp_homedir == "") {
- r_path = mdir.currentPath();
- } else {
- r_path = QString::fromStdString(cpp_homedir);
- }
- //s = AG_ShortFilename(src);
- r_path = r_path + QString::fromStdString(my_procname);
- r_path = r_path + delim;
- mdir.mkdir(r_path);
- ss = "";
- // if(s != NULL) ss = s;
- // r_path.append(ss);
- if(dst != NULL) strncpy(dst, r_path.toUtf8().constData(),
- strlen(r_path.toUtf8().constData()) >= PATH_MAX ? PATH_MAX : strlen(r_path.toUtf8().constData()));
- return;
-}
-
-_TCHAR* get_parent_dir(_TCHAR* file)
-{
-#ifdef _WINDOWS
- char delim = '\\';
-#else
- char delim = '/';
-#endif
- int ptr;
- char *p = (char *)file;
- if(file == NULL) return NULL;
- for(ptr = strlen(p) - 1; ptr >= 0; ptr--) {
- if(p[ptr] == delim) break;
- }
- if(ptr >= 0) for(ptr = ptr + 1; ptr < (int)strlen(p); ptr++) p[ptr] = '\0';
- return p;
-}
-#endif
void get_short_filename(_TCHAR *dst, _TCHAR *file, int maxlen)
{
// get module path
QString tmp_path;
tmp_path = QString::fromStdString(cpp_homedir);
- tmp_path = tmp_path + QString::fromStdString(my_procname);
#if defined(Q_OS_WIN)
const char *delim = "\\";
#else
const char *delim = "/";
#endif
+ //tmp_path = tmp_path + QString::fromUtf8(delim);
+ tmp_path = tmp_path + QString::fromUtf8("CommonSourceCodeProject");
+ tmp_path = tmp_path + QString::fromUtf8(delim);
+ tmp_path = tmp_path + QString::fromStdString(my_procname);
tmp_path = tmp_path + QString::fromUtf8(delim);
memset(app_path, 0x00, sizeof(app_path));
strncpy(app_path, tmp_path.toUtf8().constData(), _MAX_PATH);