Subversion Repositories Scribus

Rev

Rev 22825 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
1693 craig 7
#include "scpaths.h"
10223 cbradney 8
#include <QApplication>
10755 cbradney 9
#include <QDebug>
10223 cbradney 10
#include <QDir>
1693 craig 11
 
2688 craig 12
#include "scconfig.h"
2673 cbradney 13
 
1693 craig 14
// On Qt/Mac we need CoreFoundation to discover the location
15
// of the app bundle.
9596 avox 16
#ifdef Q_WS_MAC
1693 craig 17
#include <CoreFoundation/CoreFoundation.h>
18
#endif
19
 
3096 fschmid 20
#ifdef _WIN32
21
#include <windows.h>
22
#include <shlobj.h>
23
#endif
24
 
4194 fschmid 25
#ifdef _WIN32
26
const char ScPaths::envPathSeparator = ';';
27
#else
28
const char ScPaths::envPathSeparator = ':';
29
#endif
30
 
1693 craig 31
// Init the singleton's "self" address to NULL
32
ScPaths* ScPaths::m_instance = NULL;
33
 
34
// Singleton's public constructor
35
const ScPaths& ScPaths::instance()
36
{
37
        if (!ScPaths::m_instance)
38
                ScPaths::m_instance = new ScPaths();
39
        return *ScPaths::m_instance;
40
}
41
 
42
// Singleton's public destructor
43
void ScPaths::destroy()
44
{
45
        if (ScPaths::m_instance)
46
                delete ScPaths::m_instance;
47
}
48
 
49
// Protected "real" constructor
50
// All paths are initialized to compile-time defaults passed in
51
// as preprocessor macros and set by autoconf.
23989 jghali 52
ScPaths::ScPaths()
1693 craig 53
{
23989 jghali 54
// On *nix, all paths are initialized to compile-time defaults passed in
55
// as preprocessor macros and set by autoconf.
56
#if !defined(Q_WS_MAC) && !defined(_WIN32) && defined(WANT_RELOCATABLE)
57
        QString appPath = qApp->applicationDirPath();
58
        m_docDir = appPath + "/../" + QString(DOCDIR);
59
        m_iconDir = appPath + "/../" + QString(ICONDIR);
60
        m_libDir = appPath + "/../" + QString(LIBDIR);
61
        m_pluginDir = appPath + "/../" + QString(PLUGINDIR);
62
        m_sampleScriptDir = appPath + "/../" + QString(SAMPLESDIR);
63
        m_scriptDir = appPath + "/../" + QString(SCRIPTSDIR);
64
        m_shareDir = appPath + "/../" + QString(SHAREDIR);
65
        m_templateDir = appPath + "/../" + QString(TEMPLATEDIR);
66
#elif !defined(Q_WS_MAC) && !defined(_WIN32)
67
        m_docDir = QString(DOCDIR);
68
        m_iconDir = QString(ICONDIR);
69
        m_libDir = QString(LIBDIR);
70
        m_pluginDir = QString(PLUGINDIR);
71
        m_sampleScriptDir = QString(SAMPLESDIR);
72
        m_scriptDir = QString(SCRIPTSDIR);
73
        m_shareDir = QString(SHAREDIR);
74
        m_templateDir = QString(TEMPLATEDIR);
75
#endif
76
 
1693 craig 77
// On MacOS/X, override the compile-time settings with a location
78
// obtained from the system.
9596 avox 79
#ifdef Q_WS_MAC
13179 cbradney 80
        QString pathPtr(bundleDir());
81
        /*
1693 craig 82
        // Set up the various app paths to look inside the app bundle
83
        CFURLRef pluginRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
84
        CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef,
85
                                               kCFURLPOSIXPathStyle);
86
        const char *pathPtr = CFStringGetCStringPtr(macPath,
87
                                               CFStringGetSystemEncoding());
3546 avox 88
 
89
        // make sure we get the Scribus.app directory, not some subdir
90
 
91
        // strip trailing '/':
3459 avox 92
        char *p = const_cast<char*>(pathPtr + strlen(pathPtr) - 1);
2673 cbradney 93
        while (*p == '/')
94
                --p;
95
        ++p;
96
        *p = '\0';
97
        if (strcmp("/bin", p-4) == 0) {
98
                p -= 4;
99
                *p = '\0';
100
        }
101
        if (strcmp("/MacOS", p-6) == 0) {
102
                p -= 6;
103
                *p = '\0';
104
        }
105
        if (strcmp("/Contents", p-9) == 0) {
106
                p -= 9;
107
                *p = '\0';
108
        }
13179 cbradney 109
*/
10755 cbradney 110
        qDebug() << QString("scpaths: bundle at %1:").arg(pathPtr);
3794 cbradney 111
        m_shareDir = QString("%1/Contents/share/scribus/").arg(pathPtr);
12543 cbradney 112
        m_docDir = QString("%1/Contents/share/doc/scribus/").arg(pathPtr);
19761 craig 113
        m_fontDir = QString("%1/Contents/share/scribus/fonts/").arg(pathPtr);
3794 cbradney 114
        m_iconDir = QString("%1/Contents/share/scribus/icons/").arg(pathPtr);
115
        m_sampleScriptDir = QString("%1/Contents/share/scribus/samples/").arg(pathPtr);
116
        m_scriptDir = QString("%1/Contents/share/scribus/scripts/").arg(pathPtr);
117
        m_templateDir = QString("%1/Contents/share/scribus/templates/").arg(pathPtr);
19720 craig 118
        m_libDir = QString("%1/Contents/lib/").arg(pathPtr);
119
        m_pluginDir = QString("%1/Contents/lib/").arg(pathPtr);
18968 craig 120
//      QApplication::setLibraryPaths(QStringList(QString("%1/Contents/lib/qtplugins/").arg(pathPtr)));
19720 craig 121
        QApplication::addLibraryPath(QString("%1/Contents/PlugIns/").arg(pathPtr));
13179 cbradney 122
//      CFRelease(pluginRef);
123
//      CFRelease(macPath);
3546 avox 124
 
125
        // on OSX this goes to the sys console, so user only sees it when they care -- AV
10755 cbradney 126
        qDebug() << QString("scpaths: doc dir=%1").arg(m_docDir);
127
        qDebug() << QString("scpaths: icon dir=%1").arg(m_iconDir);
128
        qDebug() << QString("scpaths: font dir=%1").arg(m_fontDir);
129
        qDebug() << QString("scpaths: sample dir=%1").arg(m_sampleScriptDir);
130
        qDebug() << QString("scpaths: script dir=%1").arg(m_scriptDir);
131
        qDebug() << QString("scpaths: template dir=%1").arg(m_templateDir);
132
        qDebug() << QString("scpaths: lib dir=%1").arg(m_libDir);
133
        qDebug() << QString("scpaths: plugin dir=%1").arg(m_pluginDir);
134
        qDebug() << QString("scpaths: qtplugins=%1").arg(QApplication::libraryPaths().join(":"));
3546 avox 135
 
3096 fschmid 136
#elif defined(_WIN32)
137
        QString appPath = qApp->applicationDirPath();
3794 cbradney 138
        m_shareDir = QString("%1/share/").arg(appPath);
139
        m_docDir = QString("%1/share/doc/").arg(appPath);
140
        m_fontDir = QString("%1/share/fonts/").arg(appPath);
141
        m_iconDir = QString("%1/share/icons/").arg(appPath);
142
        m_sampleScriptDir = QString("%1/share/samples/").arg(appPath);
143
        m_scriptDir = QString("%1/share/scripts/").arg(appPath);
144
        m_templateDir = QString("%1/share/templates/").arg(appPath);
145
        m_libDir = QString("%1/libs/").arg(appPath);
146
        m_pluginDir = QString("%1/plugins/").arg(appPath);
18435 jghali 147
 
148
        QString qtpluginDir = QString("%1/qtplugins/").arg(appPath);
149
        if (QDir(qtpluginDir).exists())
150
                QApplication::setLibraryPaths( QStringList(qtpluginDir) );
3096 fschmid 151
#endif
7407 cbradney 152
 
153
//      if(!m_shareDir.endsWith("/"))        m_shareDir += "/";
154
//      if(!m_docDir.endsWith("/"))          m_docDir += "/";
155
//      if(!m_fontDir.endsWith("/"))         m_fontDir += "/";
7430 cbradney 156
        if(!m_iconDir.endsWith("/"))         m_iconDir += "/";
7407 cbradney 157
//      if(!m_sampleScriptDir.endsWith("/")) m_sampleScriptDir += "/";
158
//      if(!m_scriptDir.endsWith("/"))       m_scriptDir += "/";
159
//      if(!m_templateDir.endsWith("/"))     m_templateDir += "/";
160
//      if(!m_libDir.endsWith("/"))          m_libDir += "/";
161
//      if(!m_pluginDir.endsWith("/"))       m_pluginDir += "/";
1693 craig 162
}
163
 
164
ScPaths::~ScPaths() {};
165
 
13179 cbradney 166
QString ScPaths::bundleDir(void) const
167
{
168
        // On MacOS/X, override the compile-time settings with a location
15414 craig 169
        // obtained from the system.
13179 cbradney 170
#ifdef Q_WS_MAC
171
        // Set up the various app paths to look inside the app bundle
172
        CFURLRef pluginRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
15414 craig 173
        CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef, kCFURLPOSIXPathStyle);
174
        const char *pathPtr = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding());
175
        if (pathPtr!=NULL && strlen(pathPtr)>0)
176
        {
177
                // make sure we get the Scribus.app directory, not some subdir
178
                // strip trailing '/':
179
                qDebug("Path = %s", pathPtr);
180
                char *p = const_cast<char*>(pathPtr + strlen(pathPtr) - 1);
181
                while (*p == '/')
182
                        --p;
183
                ++p;
13179 cbradney 184
                *p = '\0';
15414 craig 185
                if (strcmp("/bin", p-4) == 0) {
186
                        p -= 4;
187
                        *p = '\0';
188
                }
189
                if (strcmp("/MacOS", p-6) == 0) {
190
                        p -= 6;
191
                        *p = '\0';
192
                }
193
                if (strcmp("/Contents", p-9) == 0) {
194
                        p -= 9;
195
                        *p = '\0';
196
                }
197
                CFRelease(pluginRef);
198
                CFRelease(macPath);
199
                return QString("%1").arg(pathPtr);
13179 cbradney 200
        }
15414 craig 201
        else
202
        {
203
                char buf[2048];
204
                CFStringGetCString (macPath, buf, 2048, kCFStringEncodingUTF8);
205
                QString q_pathPtr=QString::fromUtf8(buf);
206
                if (q_pathPtr.endsWith("/bin"))
207
                        q_pathPtr.chop(4);
208
                if (q_pathPtr.endsWith("/MacOS"))
209
                        q_pathPtr.chop(6);
210
                if (q_pathPtr.endsWith("/Contents"))
211
                        q_pathPtr.chop(9);
212
                CFRelease(pluginRef);
213
                CFRelease(macPath);
214
                return q_pathPtr;
13179 cbradney 215
        }
216
#endif
217
        return QString::null;
218
}
219
 
1693 craig 220
const QString&  ScPaths::docDir() const
221
{
222
        return m_docDir;
223
}
224
 
225
const QString&  ScPaths::iconDir() const
226
{
227
        return m_iconDir;
228
}
229
 
3794 cbradney 230
const QString&  ScPaths::fontDir() const
231
{
232
        return m_fontDir;
233
}
234
 
1693 craig 235
const QString&  ScPaths::libDir() const
236
{
237
        return m_libDir;
238
}
239
 
240
const QString&  ScPaths::pluginDir() const
241
{
242
        return m_pluginDir;
243
}
244
 
245
const QString&  ScPaths::sampleScriptDir() const
246
{
247
        return m_sampleScriptDir;
248
}
249
 
250
const QString&  ScPaths::scriptDir() const
251
{
252
        return m_scriptDir;
253
}
254
 
255
const QString&  ScPaths::templateDir() const
256
{
257
        return m_templateDir;
258
}
259
 
2707 subik 260
const QString&  ScPaths::shareDir() const
261
{
262
        return m_shareDir;
263
}
3096 fschmid 264
 
10997 jghali 265
QString ScPaths::translationDir() const
266
{
267
        return (m_shareDir + "translations/");
268
}
269
 
11120 malex 270
QString ScPaths::dictDir() const
271
{
272
        return(m_shareDir + "dicts/");
273
}
274
 
17455 craig 275
QStringList ScPaths::spellDirs() const
276
{
277
        //dictionaryPaths
278
        QString macPortsPath("/opt/local/share/hunspell/");
279
        QString finkPath("/sw/share/hunspell/");
280
        QString osxLibreOfficePath("/Applications/LibreOffice.app/Contents/share/extensions");
281
        QString osxUserLibreOfficePath(QDir::homePath()+"/Applications/LibreOffice.app/Contents/share/extensions");
282
        QString linuxLocalPath("/usr/local/share/hunspell/");
17524 craig 283
        QString linuxHunspellPath("/usr/share/hunspell/");
284
        QString linuxMyspellPath("/usr/share/myspell/");
17455 craig 285
        QString windowsLOPath("LibreOffice 3.5/share/extensions");
286
        QDir d;
287
        QStringList spellDirs;
17524 craig 288
        spellDirs.append(getUserDictDir(false));
17455 craig 289
        spellDirs.append(m_shareDir + "dicts/spelling/");
290
#ifdef Q_OS_MAC
291
        d.setPath(macPortsPath);
292
        if (d.exists())
293
                spellDirs.append(macPortsPath);
294
        d.setPath(finkPath);
295
        if (d.exists())
296
                spellDirs.append(finkPath);
297
        d.setPath(osxLibreOfficePath);
298
        if (d.exists())
17494 craig 299
        {
17495 craig 300
                QStringList dictDirFilters("dict-*");
17494 craig 301
                QStringList dictDirList(d.entryList(dictDirFilters, QDir::Dirs, QDir::Name));
302
                QString dir;
303
                foreach (dir, dictDirList)
304
                        spellDirs.append(osxLibreOfficePath + "/" + dir + "/");
305
        }
17455 craig 306
        d.setPath(osxUserLibreOfficePath);
307
        if (d.exists())
17494 craig 308
        {
17495 craig 309
                QStringList dictDirFilters("dict-*");
17494 craig 310
                QStringList dictDirList(d.entryList(dictDirFilters, QDir::Dirs, QDir::Name));
311
                QString dir;
312
                foreach (dir, dictDirList)
313
                        spellDirs.append(osxUserLibreOfficePath + "/" + dir + "/");
314
        }
315
 
17455 craig 316
#elif defined(_WIN32)
317
        QString progFiles = getSpecialDir(CSIDL_PROGRAM_FILES);
318
        d.setPath(progFiles+windowsLOPath);
319
        if (d.exists())
17494 craig 320
        {
17495 craig 321
                QStringList dictDirFilters("dict-*");
17494 craig 322
                QStringList dictDirList(d.entryList(dictDirFilters, QDir::Dirs, QDir::Name));
323
                QString dir;
324
                foreach (dir, dictDirList)
325
                        spellDirs.append(progFiles+windowsLOPath + "/" + dir + "/");
326
        }
17455 craig 327
#elif defined(Q_WS_X11)
17524 craig 328
        d.setPath(linuxHunspellPath);
17455 craig 329
        if (d.exists())
17524 craig 330
                spellDirs.append(linuxHunspellPath);
331
        d.setPath(linuxMyspellPath);
332
        if (d.exists())
333
                spellDirs.append(linuxMyspellPath);
17455 craig 334
        d.setPath(linuxLocalPath);
335
        if (d.exists())
336
                spellDirs.append(linuxLocalPath);
337
#endif
338
        return spellDirs;
339
}
340
 
3096 fschmid 341
QStringList ScPaths::getSystemFontDirs(void)
342
{
343
        QStringList fontDirs;
3102 avox 344
#ifdef Q_OS_MAC
10398 cbradney 345
        fontDirs.append(QDir::homePath() + "/Library/Fonts/");
3096 fschmid 346
        fontDirs.append("/Library/Fonts/");
347
        fontDirs.append("/Network/Library/Fonts/");
348
        fontDirs.append("/System/Library/Fonts/");
349
#elif defined(_WIN32)
22825 jghali 350
        QDir d;
351
        QString localFontDir = getSpecialDir(CSIDL_LOCAL_APPDATA)+"Microsoft/Windows/Fonts"; // Added by Windows 10 1809
352
        QString roamingFontDir = getSpecialDir(CSIDL_APPDATA)+"Microsoft/Windows/Fonts"; // Added by Windows 10 1809
353
        d.setPath(localFontDir);
354
        if (d.exists())
355
                fontDirs.append(localFontDir);
356
        d.setPath(roamingFontDir);
357
        if (d.exists())
358
                fontDirs.append(roamingFontDir);
3096 fschmid 359
        fontDirs.append( getSpecialDir(CSIDL_FONTS) );
360
#endif
361
        return fontDirs;
362
}
363
 
364
QStringList ScPaths::getSystemProfilesDirs(void)
365
{
366
        QStringList iccProfDirs;
3102 avox 367
#ifdef Q_OS_MAC
10398 cbradney 368
        iccProfDirs.append(QDir::homePath()+"/Library/ColorSync/Profiles/");
3096 fschmid 369
        iccProfDirs.append("/System/Library/ColorSync/Profiles/");
370
        iccProfDirs.append("/Library/ColorSync/Profiles/");
371
#elif defined(Q_WS_X11)
10398 cbradney 372
        iccProfDirs.append(QDir::homePath()+"/color/icc/");
373
        iccProfDirs.append(QDir::homePath()+"/.color/icc/");
18952 jghali 374
        iccProfDirs.append(QDir::homePath()+"/.local/share/icc/");
17619 craig 375
        iccProfDirs.append(QDir::homePath()+"/.local/share/color/icc/");
3096 fschmid 376
        iccProfDirs.append("/usr/share/color/icc/");
3961 mrdocs 377
        iccProfDirs.append("/usr/local/share/color/icc/");
18952 jghali 378
        iccProfDirs.append("/var/lib/color/icc/");
3096 fschmid 379
#elif defined(_WIN32)
380
        // On Windows it's more complicated, profiles location depends on OS version
10293 jghali 381
        WCHAR sysDir[MAX_PATH + 1];
3096 fschmid 382
        OSVERSIONINFO osVersion;
383
        ZeroMemory( &osVersion, sizeof(OSVERSIONINFO));
384
        osVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); // Necessary for GetVersionEx to succeed
385
        GetVersionEx(&osVersion);  // Get Windows version infos
10293 jghali 386
        GetSystemDirectoryW( sysDir, MAX_PATH ); // getSpecialDir(CSIDL_SYSTEM) fails on Win9x
387
        QString winSysDir = QString::fromUtf16((const ushort*) sysDir);
388
        winSysDir = winSysDir.replace('\\','/');
3096 fschmid 389
        if( osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT     ) // Windows NT/2k/XP
390
        {
391
                if( osVersion.dwMajorVersion >= 5 ) // for 2k and XP dwMajorVersion == 5 
392
                        iccProfDirs.append( winSysDir + "/Spool/Drivers/Color/");
393
        }
394
        else if( osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) // Windows 9x/Me 
395
        {
396
                if( osVersion.dwMajorVersion >= 4 && osVersion.dwMinorVersion >= 10) // Win98 or WinMe
397
                        iccProfDirs.append( winSysDir + "/Color/");
398
        }
399
#endif
400
        return iccProfDirs;
401
}
402
 
4805 cbradney 403
QStringList ScPaths::getSystemCreateSwatchesDirs(void)
4602 cbradney 404
{
405
        QStringList createDirs;
406
#ifdef Q_OS_MAC
10398 cbradney 407
        createDirs.append(QDir::homePath()+"/create/swatches/");
408
        createDirs.append(QDir::homePath()+"/.create/swatches/");
4602 cbradney 409
#elif defined(Q_WS_X11)
10398 cbradney 410
        createDirs.append(QDir::homePath()+"/create/swatches/");
411
        createDirs.append(QDir::homePath()+"/.create/swatches/");
4602 cbradney 412
        createDirs.append("/usr/share/create/swatches/");
413
        createDirs.append("/usr/local/share/create/swatches/");
414
#elif defined(_WIN32)
4689 mrdocs 415
        QString localAppData = getSpecialDir(CSIDL_LOCAL_APPDATA);
416
        QString commonAppData = getSpecialDir(CSIDL_COMMON_APPDATA);
417
        QString programFilesCommon = getSpecialDir(CSIDL_PROGRAM_FILES_COMMON);
418
        createDirs.append(getSpecialDir(CSIDL_APPDATA) + "create/swatches/");
419
        if ( !localAppData.isEmpty() )
420
                createDirs.append(localAppData + "create/swatches/");
421
        if ( !commonAppData.isEmpty() )
422
                createDirs.append(commonAppData + "create/swatches/");
423
        if ( !programFilesCommon.isEmpty() )
424
                createDirs.append(programFilesCommon + "create/swatches/");
4602 cbradney 425
#endif
426
        return createDirs;
427
}
428
 
5917 jghali 429
QString ScPaths::getApplicationDataDir(void)
430
{
431
#if defined(_WIN32)
432
        QString appData = getSpecialDir(CSIDL_APPDATA);
433
        if (QDir(appData).exists())
16450 craig 434
        #ifdef APPLICATION_DATA_DIR
13066 subik 435
                return (appData + "/" + APPLICATION_DATA_DIR + "/");
16450 craig 436
        #else
5917 jghali 437
                return (appData + "/Scribus/");
16450 craig 438
        #endif
5917 jghali 439
#endif
13066 subik 440
 
441
#ifdef APPLICATION_DATA_DIR
442
        return QDir::homePath() + "/" + APPLICATION_DATA_DIR + "/";
443
#else
13171 cbradney 444
        #ifdef Q_OS_MAC
445
                return (QDir::homePath() + "/Library/Preferences/Scribus/");
446
        #else
447
                return (QDir::homePath() + "/.scribus/");
448
        #endif
13066 subik 449
#endif
5917 jghali 450
}
451
 
17524 craig 452
QString ScPaths::getUserDictDir(bool createIfNotExists)
453
{
454
        QDir userDictDirectory(getApplicationDataDir() + "dicts/");
455
        if(createIfNotExists)
456
        {
457
                if (!userDictDirectory.exists())
458
                        userDictDirectory.mkpath(userDictDirectory.absolutePath());
459
        }
460
        return userDictDirectory.absolutePath()+"/";
461
}
462
 
5917 jghali 463
QString ScPaths::getUserDocumentDir(void)
464
{
465
#if defined(_WIN32)
466
        QString userDocs = getSpecialDir(CSIDL_PERSONAL);
467
        if      (QDir(userDocs).exists())
468
                return userDocs;
469
#endif
10398 cbradney 470
        return (QDir::homePath() + "/");
5917 jghali 471
}
472
 
473
QString ScPaths::getTempFileDir(void)
474
{
475
#if defined(_WIN32)
476
        QString tempPath;
477
        WCHAR wTempPath[1024];
478
        DWORD result = GetTempPathW(1024, wTempPath);
479
        if ( result )
480
        {
10293 jghali 481
                tempPath = QString::fromUtf16((const unsigned short*) wTempPath);
5917 jghali 482
                tempPath.replace( '\\', '/' );
483
                tempPath += "/";
484
                // GetTempPath may return Windows directory, better not use this one
485
                // for temporary files
486
                if (QDir(tempPath).exists() && tempPath != getSpecialDir(CSIDL_WINDOWS))
487
                        return tempPath;
488
        }
13265 cbradney 489
#endif
5917 jghali 490
        return getApplicationDataDir();
491
}
492
 
17524 craig 493
QString ScPaths::downloadDir()
494
{
495
        QDir downloadDirectory(getApplicationDataDir() + "downloads/");
496
        if (!downloadDirectory.exists())
497
                downloadDirectory.mkpath(downloadDirectory.absolutePath());
498
        return downloadDirectory.absolutePath()+"/";
499
}
500
 
4169 mrdocs 501
QString ScPaths::getSpecialDir(int folder)
3096 fschmid 502
{
503
        QString qstr;
504
#if defined(_WIN32)
10293 jghali 505
        WCHAR dir[256];
506
        if ( SHGetSpecialFolderPathW(NULL, dir, folder , false) )
4689 mrdocs 507
        {
10293 jghali 508
                qstr = QString::fromUtf16((const unsigned short*) dir);
4689 mrdocs 509
                if( !qstr.endsWith("\\") )
510
                        qstr += "\\";
511
                qstr.replace( '\\', '/' );
512
        }
3096 fschmid 513
#else
514
        Q_ASSERT(false);
515
#endif
516
        return qstr;
517
}