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.
parent
0b4b5df86f
commit
32a5c7257f
|
@ -13,9 +13,6 @@
|
|||
|
||||
@interface FilePlaylistEntry : PlaylistEntry {
|
||||
FSRef fileRef;
|
||||
NSString *fragment;
|
||||
}
|
||||
|
||||
@property(retain) NSString *fragment;
|
||||
|
||||
@end
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue