OSDN Git Service

[CONFIG] IMPORTANT: Now, "~/emufoo/foo.ini" has moved to "~/.config/CommonSourceCodeP...
authorK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 10 Feb 2018 08:43:16 +0000 (17:43 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 10 Feb 2018 08:43:16 +0000 (17:43 +0900)
source/src/qt/CMakeLists.txt
source/src/qt/avio/CMakeLists.txt
source/src/qt/common/qt_utils.cpp
source/src/qt/gui/CMakeLists.txt
source/src/qt/gui/menu_main.cpp
source/src/qt/gui/qt_main.cpp
source/src/qt/osd.cpp

index dadc216..c2013aa 100644 (file)
@@ -1,5 +1,5 @@
 message("* qt/osd")
-SET(THIS_LIB_VERSION 2.9.16
+SET(THIS_LIB_VERSION 2.10.0
 
 set(s_qt_osd_headers
        osd_base.h
index 0c62b0a..02f5677 100644 (file)
@@ -1,6 +1,6 @@
 message("* qt/avio")
 
-SET(THIS_LIB_VERSION 2.6.13)
+SET(THIS_LIB_VERSION 2.7.0)
 set(s_qt_avio_headers
          movie_saver.h
          movie_loader.h
index 3878332..dc58c77 100644 (file)
@@ -410,6 +410,8 @@ bool Ui_MainWindow::GetPowerState(void)
 }
 #endif
 
+#include <string>
+
 void Ui_MainWindow::OnMainWindowClosed(void)
 {
        // notify power off
@@ -449,7 +451,18 @@ void Ui_MainWindow::OnMainWindowClosed(void)
                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) {
@@ -492,6 +505,22 @@ extern void DLL_PREFIX_I get_long_full_path_name(_TCHAR* src, _TCHAR* dst);
 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;
@@ -523,18 +552,16 @@ static void setup_logs(void)
        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
@@ -559,8 +586,19 @@ int MainLoop(int argc, char *argv[])
        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;
 
index 7d04646..b4ad051 100644 (file)
@@ -1,6 +1,6 @@
 message("* qt/gui")
 
-set(THIS_LIB_VERSION 2.10.9)
+set(THIS_LIB_VERSION 2.11.0)
 set(s_qt_gui_headers
          csp_logger.h
   
index 77cc484..7ac43fb 100644 (file)
@@ -1214,7 +1214,6 @@ void Ui_MainWindowBase::setCoreApplication(QApplication *p)
 #include <string>
 // Move from common/qt_main.cpp
 // menu
-extern std::string cpp_homedir;
 std::string cpp_confdir;
 extern std::string my_procname;
 extern bool now_menuloop;
index 22afaeb..2a292b2 100644 (file)
@@ -23,58 +23,6 @@ extern DLL_PREFIX_I std::string cpp_confdir;
 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)
 {
index 6bd4962..0162f80 100644 (file)
@@ -1071,12 +1071,15 @@ void OSD::initialize(int rate, int samples)
        // 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);