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 {
|
@interface FilePlaylistEntry : PlaylistEntry {
|
||||||
FSRef fileRef;
|
FSRef fileRef;
|
||||||
NSString *fragment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@property(retain) NSString *fragment;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -11,12 +11,11 @@
|
||||||
|
|
||||||
@implementation FilePlaylistEntry
|
@implementation FilePlaylistEntry
|
||||||
|
|
||||||
@synthesize fragment;
|
|
||||||
|
|
||||||
- (void)setURL:(NSURL *)url
|
- (void)setURL:(NSURL *)url
|
||||||
{
|
{
|
||||||
FSPathMakeRef((UInt8 *)[[url path] fileSystemRepresentation], &fileRef, NULL);
|
FSPathMakeRef((UInt8 *)[[url path] fileSystemRepresentation], &fileRef, NULL);
|
||||||
self.fragment = [url fragment];
|
|
||||||
|
[super setURL:url];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSURL *)URL
|
- (NSURL *)URL
|
||||||
|
@ -24,14 +23,17 @@
|
||||||
UInt8 path[PATH_MAX];
|
UInt8 path[PATH_MAX];
|
||||||
|
|
||||||
OSStatus status = FSRefMakePath(&fileRef, (UInt8*)path, sizeof(path));
|
OSStatus status = FSRefMakePath(&fileRef, (UInt8*)path, sizeof(path));
|
||||||
if (status != noErr)
|
if (status == noErr)
|
||||||
return nil;
|
{
|
||||||
|
|
||||||
NSString *after = @"";
|
NSString *after = @"";
|
||||||
if (self.fragment != nil) {
|
if ([URL fragment] != nil) {
|
||||||
after = [@"#" stringByAppendingString:self.fragment];
|
after = [@"#" stringByAppendingString:[URL fragment]];
|
||||||
}
|
}
|
||||||
return [NSURL URLWithString:[[[NSURL fileURLWithPath: [NSString stringWithUTF8String:(const char *)path]] absoluteString] stringByAppendingString:after]];
|
|
||||||
|
[super setURL:[NSURL URLWithString:[[[NSURL fileURLWithPath: [NSString stringWithUTF8String:(const char *)path]] absoluteString] stringByAppendingString:after]]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue