1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-31 11:35:24 +01:00

Proper spotify settings path on Mac.

This commit is contained in:
John Maguire 2011-11-24 17:31:18 +01:00
parent 34111ce373
commit fafcef8918
2 changed files with 29 additions and 0 deletions

View File

@ -33,6 +33,7 @@ QString GetCacheDirectory() {
return user_cache + "/" + QCoreApplication::applicationName() + "/spotify-cache";
}
#ifndef Q_OS_DARWIN
QString GetSettingsDirectory() {
QSettings settings;
QString file_name = settings.fileName();
@ -41,5 +42,6 @@ QString GetSettingsDirectory() {
dir.mkdir("spotify-settings");
return info.absolutePath() + "/spotify-settings";
}
#endif
} // namespace utilities

View File

@ -1,6 +1,7 @@
#include "spotify_utilities.h"
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSFileManager.h>
#import <Foundation/NSPathUtilities.h>
namespace utilities {
@ -24,4 +25,30 @@ QString GetUserCacheDirectory() {
return ret;
}
QString GetSettingsDirectory() {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSArray* paths = NSSearchPathForDirectoriesInDomains(
NSApplicationSupportDirectory,
NSUserDomainMask,
YES);
NSString* ret;
if ([paths count] > 0) {
ret = [paths objectAtIndex:0];
} else {
ret = @"~/Library/Application Support";
}
ret = [ret stringByAppendingString:@"/Clementine/spotify-settings"];
NSFileManager* file_manager = [NSFileManager defaultManager];
[file_manager createDirectoryAtPath:
ret
withIntermediateDirectories:YES
attributes:nil
error:nil];
QString path = QString::fromUtf8([ret UTF8String]);
[pool drain];
return path;
}
}