1
/***************************************************************************
2
* Copyright 2005-2008 Last.fm Ltd. *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18
***************************************************************************/
27
#include <QCoreApplication>
28
#include <Carbon/Carbon.h>
36
return QDir( qApp->applicationDirPath() ).absoluteFilePath( "../.." );
45
if ((QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) == 0)
47
// Use this for non-DOS-based Windowses
49
HRESULT h = SHGetFolderPathA( NULL,
50
CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE,
55
return QString::fromLocal8Bit( path );
59
#elif defined(Q_WS_MAC)
61
#define EIT( x ) { OSErr err = x; if (err != noErr) throw 1; }
66
EIT( ::FindFolder( kOnAppropriateDisk,
67
kApplicationSupportFolderType,
72
// Now we have a vRefNum and a dirID - but *not* an Unix-Path as string.
73
// Lets make one based from this:
75
EIT( ::FSMakeFSSpec( vRefNum, dirId, NULL, &fsspec ) );
77
// ...and build an FSRef based on thes FSSpec.
79
EIT( ::FSpMakeFSRef( &fsspec, &fsref ) );
81
// ...then extract the Unix Path as a C-String from the FSRef
82
unsigned char path[512];
83
EIT( ::FSRefMakePath( &fsref, path, 512 ) );
85
return QDir::homePath() + QString::fromUtf8( (char*)path );
89
return QDir::home().filePath( "Library/Application Support" );
92
#elif defined(Q_WS_X11)
93
return QDir::home().filePath( ".local/share" );
103
CoreDir::programFiles()
107
// TODO: this call is dependant on a specific version of shell32.dll.
108
// Need to degrade gracefully. Need to bundle SHFolder.exe with installer
109
// and execute it on install for this to work on Win98.
110
HRESULT h = SHGetFolderPathA( NULL,
118
qCritical() << "Couldn't get Program Files dir. Possibly Win9x?";
122
return QString::fromLocal8Bit( path );