Use proper cache location for spotify on Mac too.
This commit is contained in:
parent
712745c605
commit
32af513e83
@ -21,6 +21,10 @@ set(HEADERS
|
||||
spotifyclient.h
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND SOURCES spotify_utilities.mm)
|
||||
endif(APPLE)
|
||||
|
||||
qt4_wrap_cpp(MOC ${HEADERS})
|
||||
|
||||
if(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT ENABLE_WIN32_CONSOLE)
|
||||
@ -40,6 +44,12 @@ target_link_libraries(clementine-spotifyblob
|
||||
clementine-spotifyblob-messages
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
target_link_libraries(clementine-spotifyblob
|
||||
/System/Library/Frameworks/Foundation.framework
|
||||
)
|
||||
endif(APPLE)
|
||||
|
||||
if(NOT APPLE)
|
||||
# macdeploy.py takes care of this on mac
|
||||
install(TARGETS clementine-spotifyblob
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
namespace utilities {
|
||||
|
||||
#ifndef Q_OS_DARWIN // See spotify_utilities.mm for Mac implementation.
|
||||
QString GetUserCacheDirectory() {
|
||||
#ifndef Q_OS_WINDOWS
|
||||
const char* xdg_cache_dir = getenv("XDG_CACHE_HOME");
|
||||
@ -15,14 +16,15 @@ QString GetUserCacheDirectory() {
|
||||
}
|
||||
return QString::fromLocal8Bit(xdg_cache_dir);
|
||||
|
||||
#else
|
||||
#else // Q_OS_WINDOWS
|
||||
const char* cache_dir = getenv("APPDATA");
|
||||
if (!cache_dir) {
|
||||
return QDir::homePath() + "/.config/";
|
||||
}
|
||||
return QDir::fromNativeSeparators(QString::fromLocal8Bit(cache_dir));
|
||||
#endif
|
||||
#endif // Q_OS_WINDOWS
|
||||
}
|
||||
#endif // Q_OS_DARWIN
|
||||
|
||||
QString GetCacheDirectory() {
|
||||
QString user_cache = GetUserCacheDirectory();
|
||||
|
@ -5,6 +5,9 @@
|
||||
|
||||
namespace utilities {
|
||||
|
||||
// Get the path to the current user's local cache for all apps.
|
||||
QString GetUserCacheDirectory();
|
||||
// Get the path for Clementine's cache.
|
||||
QString GetCacheDirectory();
|
||||
|
||||
}
|
||||
|
27
spotifyblob/blob/spotify_utilities.mm
Normal file
27
spotifyblob/blob/spotify_utilities.mm
Normal file
@ -0,0 +1,27 @@
|
||||
#include "spotify_utilities.h"
|
||||
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
|
||||
namespace utilities {
|
||||
|
||||
QString GetUserCacheDirectory() {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user