Initial commit
[keepassx] / src / main_win32.cpp
1 /***************************************************************************
2  *   Copyright (C) 1992-2007 Trolltech ASA                                                                 *
3  *                                                                         *
4  *   Copyright (C) 2005-2007 by Tarek Saidi                                *
5  *   tarek.saidi@arcor.de                                                  *
6  *                                                                         *
7  *   This program is free software; you can redistribute it and/or modify  *
8  *   it under the terms of the GNU General Public License as published by  *
9  *   the Free Software Foundation; version 2 of the License.               *
10  *                                                                         *
11  *   This program is distributed in the hope that it will be useful,       *
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14  *   GNU General Public License for more details.                          *
15  *                                                                         *
16  *   You should have received a copy of the GNU General Public License     *
17  *   along with this program; if not, write to the                         *
18  *   Free Software Foundation, Inc.,                                       *
19  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
20  ***************************************************************************/
21
22 #include <windows.h>
23 #include "main.h"
24
25 void initAppPaths(int argc,char** argv){
26         QFileInfo filePath;
27         QT_WA({
28                 wchar_t module_name[256];
29                 GetModuleFileNameW(0, module_name, sizeof(module_name) / sizeof(wchar_t));
30                 filePath = QString::fromUtf16((ushort *)module_name);
31         }, {
32                 char module_name[256];
33                 GetModuleFileNameA(0, module_name, sizeof(module_name));
34                 filePath = QString::fromLocal8Bit(module_name);
35         });     
36         AppDir = filePath.filePath();
37         AppDir.truncate(AppDir.lastIndexOf("/"));
38         
39         HomeDir = QString::fromLocal8Bit(qgetenv("APPDATA").constData());
40         if(!HomeDir.isEmpty() && QFile::exists(HomeDir))
41                 HomeDir = QDir::fromNativeSeparators(HomeDir)+"/KeePassX";
42         else
43                 HomeDir = QDir::homePath()+"/KeePassX";
44         
45         DataDir=AppDir+"/share";
46 }