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.

CQTexperiment
vspader 2008-05-21 11:27:01 +00:00
parent 0b4b5df86f
commit 32a5c7257f
2 changed files with 11 additions and 12 deletions

View File

@ -13,9 +13,6 @@
@interface FilePlaylistEntry : PlaylistEntry {
FSRef fileRef;
NSString *fragment;
}
@property(retain) NSString *fragment;
@end

View File

@ -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