Skip to content

Commit 9337342

Browse files
committed
Change type of persistent ids from NSString to opaque
1 parent ea0b79c commit 9337342

4 files changed

+36
-51
lines changed

IFSiTunesLibrary.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
/* helpers */
6565

66-
- (IFSiTunesTrack *)trackWithID:(NSString *)_trackID;
66+
- (IFSiTunesTrack *)trackWithID:(id)_trackID;
6767

6868
/* burn folder helpers */
6969

IFSiTunesLibrary.m

+29-44
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3131
*/
3232

3333
#import "common.h"
34-
#import "IFSiTunesLibrary.h"
3534
#import <AppKit/AppKit.h>
35+
#import "IFSiTunesLibrary.h"
36+
37+
#import "NSObject+FUSEOFS.h"
3638
#import "NSString+Extensions.h"
39+
3740
#import "IFSiTunesPlaylist.h"
3841
#import "IFSM3UPlaylist.h"
3942
#import "IFSiTunesTrack.h"
40-
#import "NSObject+FUSEOFS.h"
4143
#import "IFSFormatter.h"
4244
#import "FUSEOFSMemoryContainer.h"
4345
#ifndef GNU_GUI_LIBRARY
@@ -169,24 +171,18 @@ - (void)dealloc {
169171
/* setup */
170172

171173
- (void)reload {
172-
NSData *plist;
173-
NSDictionary *lib;
174-
NSArray *playlists;
175-
NSDictionary *tracks;
176-
NSArray *trackIDs;
177-
NSUInteger i, count;
178-
179174
if (doDebug)
180175
NSLog(@"%s", __PRETTY_FUNCTION__);
181176

182177
[self->plMap removeAllObjects];
183178
[self->m3uMap removeAllObjects];
184179
[self->trackMap removeAllObjects];
185180

186-
plist = [NSData dataWithContentsOfFile:[self libraryPath]];
181+
NSData *plist = [NSData dataWithContentsOfFile:[self libraryPath]];
187182
NSAssert1(plist != nil, @"Couldn't read contents of %@!",
188183
[self libraryPath]);
189184

185+
NSDictionary *lib;
190186
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000
191187
lib = [NSPropertyListSerialization propertyListFromData:plist
192188
mutabilityOption:NSPropertyListImmutable
@@ -205,10 +201,10 @@ - (void)reload {
205201
self->name = [[NSString stringWithFormat:@"iTunes (v%@)",
206202
[lib objectForKey:@"Application Version"]] copy];
207203

208-
tracks = [lib objectForKey:@"Tracks"];
209-
trackIDs = [tracks allKeys];
210-
count = [trackIDs count];
211-
for (i = 0; i < count; i++) {
204+
NSDictionary *tracks = [lib objectForKey:@"Tracks"];
205+
NSArray *trackIDs = [tracks allKeys];
206+
NSUInteger count = [trackIDs count];
207+
for (NSUInteger i = 0; i < count; i++) {
212208
NSString *trackID;
213209
NSDictionary *rep;
214210
IFSiTunesTrack *track;
@@ -221,50 +217,39 @@ - (void)reload {
221217
[track release];
222218
}
223219

224-
NSMutableDictionary *idPlMap;
225-
playlists = [lib objectForKey:@"Playlists"];
226-
count = [playlists count];
227-
idPlMap = [[NSMutableDictionary alloc] initWithCapacity:count];
220+
NSArray *playlists = [lib objectForKey:@"Playlists"];
221+
count = [playlists count];
222+
NSMutableDictionary *idPlMap = [[NSMutableDictionary alloc]
223+
initWithCapacity:count];
228224

229-
for (i = 0; i < count; i++) {
230-
NSDictionary *plRep;
231-
IFSiTunesPlaylist *pl;
232-
NSString *plId;
233-
234-
plRep = [playlists objectAtIndex:i];
235-
pl = [[IFSiTunesPlaylist alloc] initWithLibraryRepresentation:plRep
236-
lib:self];
225+
for (NSUInteger i = 0; i < count; i++) {
226+
NSDictionary *plRep = [playlists objectAtIndex:i];
227+
IFSiTunesPlaylist *pl = [[IFSiTunesPlaylist alloc]
228+
initWithLibraryRepresentation:plRep
229+
lib:self];
237230

238231
// only record top-level playlist, if playlist isn't a folder itself
239232
if (![pl parentId]) {
240233
[self->plMap setItem:pl
241234
forName:[self burnFolderNameFromFolderName:[pl name]]];
242235
}
243236

244-
plId = [pl persistentId];
237+
id plId = [pl persistentId];
245238
if (plId)
246239
[idPlMap setObject:pl forKey:plId];
247240
[pl release];
248241
}
249242

250243
// connect children to their parents
251244
if ([idPlMap count]) {
252-
NSArray *ids;
253-
254-
ids = [idPlMap allKeys];
245+
NSArray *ids = [idPlMap allKeys];
255246
count = [ids count];
256-
for (i = 0; i < count; i++) {
257-
NSString *plId;
258-
IFSiTunesPlaylist *pl;
259-
NSString *parentId;
260-
261-
plId = [ids objectAtIndex:i];
262-
pl = [idPlMap objectForKey:plId];
263-
parentId = [pl parentId];
247+
for (NSUInteger i = 0; i < count; i++) {
248+
id plId = [ids objectAtIndex:i];
249+
IFSiTunesPlaylist *pl = [idPlMap objectForKey:plId];
250+
id parentId = [pl parentId];
264251
if (parentId) {
265-
IFSiTunesPlaylist *parent;
266-
267-
parent = [idPlMap objectForKey:parentId];
252+
IFSiTunesPlaylist *parent = [idPlMap objectForKey:parentId];
268253
if (parent) {
269254
[parent addChild:pl
270255
withName:[self burnFolderNameFromFolderName:[pl name]]];
@@ -282,8 +267,8 @@ - (void)reload {
282267
continue;
283268

284269
IFSM3UPlaylist *m3uPl = [[IFSM3UPlaylist alloc]
285-
initWithPlaylist:pl
286-
useRelativePaths:NO];
270+
initWithPlaylist:pl
271+
useRelativePaths:NO];
287272
[self->m3uMap setItem:m3uPl forName:[m3uPl fileName]];
288273
[m3uPl release];
289274
}
@@ -460,7 +445,7 @@ - (IFSiTunesPlaylist *)playlistNamed:(NSString *)_plName {
460445
}
461446

462447

463-
- (IFSiTunesTrack *)trackWithID:(NSString *)_trackID {
448+
- (IFSiTunesTrack *)trackWithID:(id)_trackID {
464449
return [self->trackMap objectForKey:_trackID];
465450
}
466451

IFSiTunesPlaylist.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949

5050
@interface IFSiTunesPlaylist : NSObject
5151
{
52-
NSString *persistentId;
53-
NSString *parentId;
52+
id persistentId;
53+
id parentId;
5454
NSString *name;
5555
NSMutableArray *savedTracks;
5656
NSMutableArray *tracks;
@@ -68,8 +68,8 @@
6868
- (NSDate *)modificationDate;
6969

7070
- (NSString *)name;
71-
- (NSString *)persistentId;
72-
- (NSString *)parentId;
71+
- (id)persistentId;
72+
- (id)parentId;
7373
- (NSArray *)tracks;
7474

7575
- (NSUInteger)count;

IFSiTunesPlaylist.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,10 @@ - (NSDate *)modificationDate {
243243
return self->modificationDate;
244244
}
245245

246-
- (NSString *)persistentId {
246+
- (id)persistentId {
247247
return self->persistentId;
248248
}
249-
- (NSString *)parentId {
249+
- (id)parentId {
250250
return self->parentId;
251251
}
252252

0 commit comments

Comments
 (0)