1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-16 19:31:02 +01:00
Clementine-audio-player-Mac.../ext/clementine-spotifyblob/spotify_utilities.mm

49 lines
1.4 KiB
Plaintext
Raw Normal View History

#include "spotify_utilities.h"
#import <Foundation/NSAutoreleasePool.h>
2011-11-24 17:31:18 +01:00
#import <Foundation/NSFileManager.h>
#import <Foundation/NSPathUtilities.h>
namespace utilities {
QString GetUserDataDirectory() {
NSAutoreleasePool* pool = [NSAutoreleasePool alloc];
[pool init];
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,
NSUserDomainMask, YES);
QString ret;
if ([paths count] > 0) {
NSString* user_path = [paths objectAtIndex:0];
ret = QString::fromUtf8([user_path UTF8String]);
} else {
ret = "~/Library/Caches";
}
[pool drain];
return ret;
}
2011-11-24 17:31:18 +01:00
QString GetSettingsDirectory() {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSArray* paths = NSSearchPathForDirectoriesInDomains(
NSApplicationSupportDirectory, NSUserDomainMask, YES);
2011-11-24 17:31:18 +01:00
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];
2011-11-24 17:31:18 +01:00
QString path = QString::fromUtf8([ret UTF8String]);
[pool drain];
return path;
}
}