From 32a5c7257f5de6304fc739437508be307cbc2d36 Mon Sep 17 00:00:00 2001 From: vspader Date: Wed, 21 May 2008 11:27:01 +0000 Subject: [PATCH] Slightly improved file-tracking playlist entry. Now will default to the last URL it looked up/received of the file if the path is no longer found, which helps in the case where a network share was disconnected. --- Playlist/FilePlaylistEntry.h | 3 --- Playlist/FilePlaylistEntry.m | 20 +++++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Playlist/FilePlaylistEntry.h b/Playlist/FilePlaylistEntry.h index 7e312bf27..a5ce6b231 100644 --- a/Playlist/FilePlaylistEntry.h +++ b/Playlist/FilePlaylistEntry.h @@ -13,9 +13,6 @@ @interface FilePlaylistEntry : PlaylistEntry { FSRef fileRef; - NSString *fragment; } -@property(retain) NSString *fragment; - @end diff --git a/Playlist/FilePlaylistEntry.m b/Playlist/FilePlaylistEntry.m index 2e760d5c6..743c469e2 100644 --- a/Playlist/FilePlaylistEntry.m +++ b/Playlist/FilePlaylistEntry.m @@ -11,12 +11,11 @@ @implementation FilePlaylistEntry -@synthesize fragment; - - (void)setURL:(NSURL *)url { FSPathMakeRef((UInt8 *)[[url path] fileSystemRepresentation], &fileRef, NULL); - self.fragment = [url fragment]; + + [super setURL:url]; } - (NSURL *)URL @@ -24,14 +23,17 @@ UInt8 path[PATH_MAX]; OSStatus status = FSRefMakePath(&fileRef, (UInt8*)path, sizeof(path)); - if (status != noErr) - return nil; + if (status == noErr) + { + NSString *after = @""; + if ([URL fragment] != nil) { + after = [@"#" stringByAppendingString:[URL fragment]]; + } - NSString *after = @""; - if (self.fragment != nil) { - after = [@"#" stringByAppendingString:self.fragment]; + [super setURL:[NSURL URLWithString:[[[NSURL fileURLWithPath: [NSString stringWithUTF8String:(const char *)path]] absoluteString] stringByAppendingString:after]]]; } - return [NSURL URLWithString:[[[NSURL fileURLWithPath: [NSString stringWithUTF8String:(const char *)path]] absoluteString] stringByAppendingString:after]]; + + return URL; } @end