2011-07-07 17:12:29 +02:00
|
|
|
#include "spotify_utilities.h"
|
|
|
|
|
|
|
|
#import <Foundation/NSAutoreleasePool.h>
|
2011-11-24 17:31:18 +01:00
|
|
|
#import <Foundation/NSFileManager.h>
|
2011-07-07 17:12:29 +02:00
|
|
|
#import <Foundation/NSPathUtilities.h>
|
|
|
|
|
2015-03-02 17:50:23 +01:00
|
|
|
#import "core/scoped_nsautorelease_pool.h"
|
|
|
|
|
2011-07-07 17:12:29 +02:00
|
|
|
namespace utilities {
|
|
|
|
|
2012-08-04 18:16:06 +02:00
|
|
|
QString GetUserDataDirectory() {
|
2015-03-02 17:50:23 +01:00
|
|
|
ScopedNSAutoreleasePool pool;
|
2011-07-07 17:12:29 +02:00
|
|
|
|
2020-09-18 16:15:19 +02:00
|
|
|
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
2011-07-07 17:12:29 +02:00
|
|
|
QString ret;
|
|
|
|
if ([paths count] > 0) {
|
|
|
|
NSString* user_path = [paths objectAtIndex:0];
|
|
|
|
ret = QString::fromUtf8([user_path UTF8String]);
|
|
|
|
} else {
|
|
|
|
ret = "~/Library/Caches";
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-11-24 17:31:18 +01:00
|
|
|
QString GetSettingsDirectory() {
|
2015-03-02 17:50:23 +01:00
|
|
|
ScopedNSAutoreleasePool pool;
|
2020-09-18 16:15:19 +02:00
|
|
|
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];
|
2020-09-18 16:15:19 +02:00
|
|
|
[file_manager createDirectoryAtPath:ret withIntermediateDirectories:YES attributes:nil error:nil];
|
2011-11-24 17:31:18 +01:00
|
|
|
|
|
|
|
QString path = QString::fromUtf8([ret UTF8String]);
|
|
|
|
return path;
|
|
|
|
}
|
2015-03-02 17:50:23 +01:00
|
|
|
|
|
|
|
} // namespace utilities
|