1 /***************************************************************************
2 * Copyright (C) 1992-2008 Trolltech ASA *
4 * Copyright (C) 2005-2008 by Tarek Saidi *
5 * tarek.saidi@arcor.de *
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. *
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. *
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 ***************************************************************************/
22 #include <QVarLengthArray>
23 #include <Carbon/Carbon.h>
26 void initAppPaths(int argc,char** argv) {
27 CFURLRef bundleURL(CFBundleCopyExecutableURL(CFBundleGetMainBundle()));
29 CFStringRef cfPath(CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle));
31 CFIndex length = CFStringGetLength(cfPath);
32 const UniChar *chars = CFStringGetCharactersPtr(cfPath);
34 AppDir = QString(reinterpret_cast<const QChar *>(chars), length);
37 QVarLengthArray<UniChar> buffer(length);
38 CFStringGetCharacters(cfPath, CFRangeMake(0, length), buffer.data());
39 AppDir = QString(reinterpret_cast<const QChar *>(buffer.constData()), length);
41 AppDir.truncate(AppDir.lastIndexOf("/"));
42 HomeDir = QDir::homePath()+"/.keepassx";
43 DataDir=AppDir+"/../Resources/keepassx";