From 6f6b01b15c60b9bcf54703220c9464afb222596e Mon Sep 17 00:00:00 2001 From: vspader Date: Sat, 13 Oct 2007 04:53:48 +0000 Subject: [PATCH] Fixed bug where playlist saved as kss files. Fixed bug where multi-track files were consolidated into a single entry on saving/loading a playlist. --- Application/AppController.m | 2 +- Playlist/PlaylistLoader.h | 1 + Playlist/PlaylistLoader.m | 33 ++++++--------------------------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/Application/AppController.m b/Application/AppController.m index ddd6c3c0b..945ef235d 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -150,7 +150,7 @@ increase/decrease as long as the user holds the left/right, plus/minus button */ p = [NSSavePanel savePanel]; - [p setAllowedFileTypes:[playlistLoader acceptableContainerTypes]]; + [p setAllowedFileTypes:[playlistLoader acceptablePlaylistTypes]]; [p beginSheetForDirectory:nil file:nil modalForWindow:mainWindow modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:NULL]; } diff --git a/Playlist/PlaylistLoader.h b/Playlist/PlaylistLoader.h index e55cc77d0..e3e33eab2 100755 --- a/Playlist/PlaylistLoader.h +++ b/Playlist/PlaylistLoader.h @@ -31,6 +31,7 @@ typedef enum { - (BOOL)savePls:(NSString *)filename; - (NSArray *)acceptableFileTypes; +- (NSArray *)acceptablePlaylistTypes; //Only m3u and pls saving - (NSArray *)acceptableContainerTypes; @end diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index 968afedd4..1301ff6c1 100755 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -48,7 +48,7 @@ { NSString *basePath = [[[filename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"]; - if ([entryURL isFileURL]) { + if ([entryURL isFileURL] && [[entryURL fragment] isEqualToString:@""]) { //We want relative paths. NSMutableString *entryPath = [[[[entryURL path] stringByStandardizingPath] mutableCopy] autorelease]; @@ -62,32 +62,6 @@ } } -- (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename -{ - if ([path hasPrefix:@"/"]) { - return [NSURL fileURLWithPath:path]; - } - - NSEnumerator *e = [[AudioPlayer schemes] objectEnumerator]; - NSString *scheme; - while (scheme = [e nextObject]) - { - if ([path hasPrefix:[scheme stringByAppendingString:@"://"]]) - { - return [NSURL URLWithString:path]; - } - } - - NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"]; - NSMutableString *unixPath = [path mutableCopy]; - - //Only relative paths would have windows backslashes. - [unixPath replaceOccurrencesOfString:@"\\" withString:@"/" options:0 range:NSMakeRange(0, [unixPath length])]; - - return [NSURL fileURLWithPath:[basePath stringByAppendingString:[unixPath autorelease]]]; -} - - - (BOOL)saveM3u:(NSString *)filename { NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:filename createFile:YES]; @@ -318,6 +292,11 @@ return [[self acceptableContainerTypes] arrayByAddingObjectsFromArray:[AudioPlayer fileTypes]]; } +- (NSArray *)acceptablePlaylistTypes +{ + return [NSArray arrayWithObjects:@"m3u", @"pls", nil]; +} + - (NSArray *)acceptableContainerTypes { return [AudioPlayer containerTypes];