OSDN Git Service

f8d1a5e0ef2220aa0783d343a3b3f6e427adf6cd
[csp-qt/common_source_project-fm7.git] / source / src / qt / gui / qt_main.cpp
1 /*
2         Skelton for retropc emulator
3         Author : Takeda.Toshiya
4         Port to Qt : K.Ohta <whatisthis.sowhat _at_ gmail.com>
5         Date   : 2006.08.18 -
6
7         [ win32 main ] -> [ agar main ]
8 */
9
10 #include <stdio.h>
11 #include <string>
12 #include <vector>
13 #include <QString>
14 #include <QDir>
15
16 #include "common.h"
17 #include "fileio.h"
18 #include "menu_flags.h"
19
20 extern std::string cpp_homedir;
21 extern std::string cpp_confdir;
22 extern std::string my_procname;
23 extern std::string sRssDir;
24
25 void get_long_full_path_name(_TCHAR* src, _TCHAR* dst)
26 {
27         QString r_path;
28         QString delim;
29         QString ss;
30         const char *s;
31         QDir mdir;
32         if(src == NULL) {
33                 if(dst != NULL) dst[0] = '\0';
34                 return;
35         }
36 #ifdef _WINDOWS
37         delim = "\\";
38 #else
39         delim = "/";
40 #endif
41         ss = "";
42         if(cpp_homedir == "") {
43                 r_path = mdir.currentPath();
44         } else {
45                 r_path = QString::fromStdString(cpp_homedir);
46         }
47         //s = AG_ShortFilename(src);
48         r_path = r_path + QString::fromStdString(my_procname);
49         r_path = r_path + delim;
50         mdir.mkdir(r_path);
51         ss = "";
52         //  if(s != NULL) ss = s;
53         //  r_path.append(ss);
54         if(dst != NULL) strncpy(dst, r_path.toUtf8().constData(),
55                                 strlen(r_path.toUtf8().constData()) >= PATH_MAX ? PATH_MAX : strlen(r_path.toUtf8().constData()));
56         return;
57 }
58
59 _TCHAR* get_parent_dir(_TCHAR* file)
60 {
61 #ifdef _WINDOWS
62         char delim = '\\';
63 #else
64         char delim = '/';
65 #endif
66         int ptr;
67         char *p = (char *)file;
68         if(file == NULL) return NULL;
69         for(ptr = strlen(p) - 1; ptr >= 0; ptr--) { 
70                 if(p[ptr] == delim) break;
71         }
72         if(ptr >= 0) for(ptr = ptr + 1; ptr < strlen(p); ptr++) p[ptr] = '\0'; 
73         return p;
74 }
75
76 void get_short_filename(_TCHAR *dst, _TCHAR *file, int maxlen)
77 {
78         int i, l;
79         if((dst == NULL) || (file == NULL)) return;
80 #ifdef _WINDOWS
81         _TCHAR delim = '\\';
82 #else
83         _TCHAR delim = '/';
84 #endif
85         for(i = strlen(file) - 1; i <= 0; i--) {
86                 if(file[i] == delim) break;
87         }
88         if(i >= (strlen(file) - 1)) {
89                 dst[0] = '\0';
90                 return;
91         }
92         l = strlen(file) - i + 1;
93         if(l >= maxlen) l = maxlen;
94         strncpy(dst, &file[i + 1], l);
95         return;
96 }
97
98 extern int MainLoop(int argc, char *argv[]);
99
100 /*
101  * This is main for Qt.
102  */
103 int main(int argc, char *argv[])
104 {
105         int nErrorCode;
106         /*
107          * Get current DIR
108          */
109    
110 /*
111  * アプリケーション初期化
112  */
113         nErrorCode = MainLoop(argc, argv);
114         return nErrorCode;
115 }
116 #if defined(Q_OS_WIN) 
117 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
118 {
119    char *arg[1] = {""};
120    main(1, arg);
121 }
122 #endif