From 94201b5a4fb2f6a0ef5c1b5eb895bca3e27e4523 Mon Sep 17 00:00:00 2001 From: vspader Date: Wed, 7 Mar 2007 01:45:45 +0000 Subject: [PATCH] added basic scanner for loading pls files. --- Playlist/PlaylistLoader.m | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index 3e1f2b60f..f35545e33 100755 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -119,15 +119,25 @@ return NO; } - NSArray *entries = [contents componentsSeparatedByString:@"\n"]; - NSString *entry; - NSEnumerator *e = [entries objectEnumerator]; + NSEnumerator *e = [[contents componentsSeparatedByString:@"\n"] objectEnumerator]; while (entry = [e nextObject]) { - NSString * + NSString *lhs = nil; + if (![scanner scanUpToString:@"=" intoString:&lhs]) //get LHS + continue; + if (![scanner scanString:@"=" intoString:nil]) //skip the = + continue; + NSString *nameString = nil; + if (![scanner scanUpToString:@"" intoString:&rhs]) //get RHS + continue; + + if (![lhs isEqualToString:@"File"]) + continue; + //get url if its a file? +// [entries addObject:nameString]; } [playlistController addURLs:urls]; @@ -144,13 +154,14 @@ NSEnumerator *e = [[playlistController content] objectEnumerator]; PlaylistEntry *pe; - + int i = 1; while (pe = [e nextObject]) { NSString *path = [self pathRelativeTo:filename forEntry:pe]; NSString *entry = [NSString stringWithFormat:@"File%i=%@\n",i,path]; [fileHandle writeData:[entry dataUsingEncoding:NSUTF8StringEncoding]]; + i++; } [self setCurrentFile:filename];