~ubuntu-branches/ubuntu/saucy/clementine/saucy

« back to all changes in this revision

Viewing changes to spotifyblob/blob/spotify_utilities.mm

  • Committer: Package Import Robot
  • Author(s): Thomas PIERSON
  • Date: 2012-01-01 20:43:39 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120101204339-lsb6nndwhfy05sde
Tags: 1.0.1+dfsg-1
New upstream release. (Closes: #653926, #651611, #657391)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "spotify_utilities.h"
 
2
 
 
3
#import <Foundation/NSAutoreleasePool.h>
 
4
#import <Foundation/NSFileManager.h>
 
5
#import <Foundation/NSPathUtilities.h>
 
6
 
 
7
namespace utilities {
 
8
 
 
9
QString GetUserCacheDirectory() {
 
10
  NSAutoreleasePool* pool = [NSAutoreleasePool alloc];
 
11
  [pool init];
 
12
 
 
13
  NSArray* paths = NSSearchPathForDirectoriesInDomains(
 
14
      NSCachesDirectory,
 
15
      NSUserDomainMask,
 
16
      YES);
 
17
  QString ret;
 
18
  if ([paths count] > 0) {
 
19
    NSString* user_path = [paths objectAtIndex:0];
 
20
    ret = QString::fromUtf8([user_path UTF8String]);
 
21
  } else {
 
22
    ret = "~/Library/Caches";
 
23
  }
 
24
  [pool drain];
 
25
  return ret;
 
26
}
 
27
 
 
28
QString GetSettingsDirectory() {
 
29
  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 
30
  NSArray* paths = NSSearchPathForDirectoriesInDomains(
 
31
      NSApplicationSupportDirectory,
 
32
      NSUserDomainMask,
 
33
      YES);
 
34
  NSString* ret;
 
35
  if ([paths count] > 0) {
 
36
    ret = [paths objectAtIndex:0];
 
37
  } else {
 
38
    ret = @"~/Library/Application Support";
 
39
  }
 
40
  ret = [ret stringByAppendingString:@"/Clementine/spotify-settings"];
 
41
 
 
42
  NSFileManager* file_manager = [NSFileManager defaultManager];
 
43
  [file_manager createDirectoryAtPath:
 
44
      ret
 
45
      withIntermediateDirectories:YES
 
46
      attributes:nil
 
47
      error:nil];
 
48
 
 
49
  QString path = QString::fromUtf8([ret UTF8String]);
 
50
  [pool drain];
 
51
  return path;
 
52
}
 
53
 
 
54
}