Fixed playlist saving/loading bug.
This commit is contained in:
parent
bc212f3e96
commit
47582ae4f4
3 changed files with 64 additions and 64 deletions
|
@ -18,10 +18,6 @@
|
||||||
|
|
||||||
- (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
- (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
||||||
{
|
{
|
||||||
if ([path hasPrefix:@"/"]) {
|
|
||||||
return [NSURL URLWithString:[@"file://" stringByAppendingString:path]];
|
|
||||||
}
|
|
||||||
|
|
||||||
NSRange protocolRange = [path rangeOfString:@"://"];
|
NSRange protocolRange = [path rangeOfString:@"://"];
|
||||||
if (protocolRange.location != NSNotFound)
|
if (protocolRange.location != NSNotFound)
|
||||||
{
|
{
|
||||||
|
@ -29,24 +25,28 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
NSMutableString *unixPath = [path mutableCopy];
|
NSMutableString *unixPath = [path mutableCopy];
|
||||||
|
|
||||||
|
NSString *fragment = @"";
|
||||||
|
NSRange fragmentRange = [path rangeOfString:@"#"];
|
||||||
|
if (fragmentRange.location != NSNotFound)
|
||||||
|
{
|
||||||
|
fragmentRange = NSMakeRange(fragmentRange.location, [unixPath length] - fragmentRange.location);
|
||||||
|
|
||||||
|
fragment = [unixPath substringWithRange:fragmentRange];
|
||||||
|
[unixPath deleteCharactersInRange:fragmentRange];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (![unixPath hasPrefix:@"/"]) {
|
||||||
|
//Only relative paths would have windows backslashes.
|
||||||
|
[unixPath replaceOccurrencesOfString:@"\\" withString:@"/" options:0 range:NSMakeRange(0, [unixPath length])];
|
||||||
|
|
||||||
|
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
||||||
|
|
||||||
|
[unixPath insertString:basePath atIndex:0];
|
||||||
|
}
|
||||||
|
|
||||||
//Only relative paths would have windows backslashes.
|
//Append the fragment
|
||||||
[unixPath replaceOccurrencesOfString:@"\\" withString:@"/" options:0 range:NSMakeRange(0, [unixPath length])];
|
return [NSURL URLWithString:[[[NSURL fileURLWithPath:unixPath] absoluteString] stringByAppendingString: fragment]];
|
||||||
|
|
||||||
NSMutableString *urlString = [[NSMutableString alloc] init];
|
|
||||||
[urlString setString:@"file://"];
|
|
||||||
|
|
||||||
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
|
||||||
|
|
||||||
[urlString appendString:basePath];
|
|
||||||
[urlString appendString:unixPath];
|
|
||||||
|
|
||||||
[unixPath release];
|
|
||||||
|
|
||||||
NSURL *url = [NSURL URLWithString:urlString];
|
|
||||||
[urlString release];
|
|
||||||
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)parseFile:(NSString *)filename
|
- (void)parseFile:(NSString *)filename
|
||||||
|
|
|
@ -23,10 +23,6 @@
|
||||||
|
|
||||||
+ (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
+ (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
||||||
{
|
{
|
||||||
if ([path hasPrefix:@"/"]) {
|
|
||||||
return [NSURL URLWithString:[@"file://" stringByAppendingString:path]];
|
|
||||||
}
|
|
||||||
|
|
||||||
NSRange protocolRange = [path rangeOfString:@"://"];
|
NSRange protocolRange = [path rangeOfString:@"://"];
|
||||||
if (protocolRange.location != NSNotFound)
|
if (protocolRange.location != NSNotFound)
|
||||||
{
|
{
|
||||||
|
@ -34,24 +30,28 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
NSMutableString *unixPath = [path mutableCopy];
|
NSMutableString *unixPath = [path mutableCopy];
|
||||||
|
|
||||||
|
NSString *fragment = @"";
|
||||||
|
NSRange fragmentRange = [path rangeOfString:@"#"];
|
||||||
|
if (fragmentRange.location != NSNotFound)
|
||||||
|
{
|
||||||
|
fragmentRange = NSMakeRange(fragmentRange.location, [unixPath length] - fragmentRange.location);
|
||||||
|
|
||||||
|
fragment = [unixPath substringWithRange:fragmentRange];
|
||||||
|
[unixPath deleteCharactersInRange:fragmentRange];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (![unixPath hasPrefix:@"/"]) {
|
||||||
|
//Only relative paths would have windows backslashes.
|
||||||
|
[unixPath replaceOccurrencesOfString:@"\\" withString:@"/" options:0 range:NSMakeRange(0, [unixPath length])];
|
||||||
|
|
||||||
|
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
||||||
|
|
||||||
|
[unixPath insertString:basePath atIndex:0];
|
||||||
|
}
|
||||||
|
|
||||||
//Only relative paths would have windows backslashes.
|
//Append the fragment
|
||||||
[unixPath replaceOccurrencesOfString:@"\\" withString:@"/" options:0 range:NSMakeRange(0, [unixPath length])];
|
return [NSURL URLWithString:[[[NSURL fileURLWithPath:unixPath] absoluteString] stringByAppendingString: fragment]];
|
||||||
|
|
||||||
NSMutableString *urlString = [[NSMutableString alloc] init];
|
|
||||||
[urlString setString:@"file://"];
|
|
||||||
|
|
||||||
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
|
||||||
|
|
||||||
[urlString appendString:basePath];
|
|
||||||
[urlString appendString:unixPath];
|
|
||||||
|
|
||||||
[unixPath release];
|
|
||||||
|
|
||||||
NSURL *url = [NSURL URLWithString:urlString];
|
|
||||||
[urlString release];
|
|
||||||
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray *)urlsForContainerURL:(NSURL *)url
|
+ (NSArray *)urlsForContainerURL:(NSURL *)url
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//Need to add basePath, and convert to URL
|
//Need to add basePath, and convert to URL
|
||||||
[entries addObject:[M3uContainer urlForPath:entry relativeTo:filename]];
|
[entries addObject:[self urlForPath:entry relativeTo:filename]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return entries;
|
return entries;
|
||||||
|
|
|
@ -23,10 +23,6 @@
|
||||||
|
|
||||||
+ (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
+ (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
||||||
{
|
{
|
||||||
if ([path hasPrefix:@"/"]) {
|
|
||||||
return [NSURL URLWithString:[@"file://" stringByAppendingString:path]];
|
|
||||||
}
|
|
||||||
|
|
||||||
NSRange protocolRange = [path rangeOfString:@"://"];
|
NSRange protocolRange = [path rangeOfString:@"://"];
|
||||||
if (protocolRange.location != NSNotFound)
|
if (protocolRange.location != NSNotFound)
|
||||||
{
|
{
|
||||||
|
@ -34,24 +30,28 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
NSMutableString *unixPath = [path mutableCopy];
|
NSMutableString *unixPath = [path mutableCopy];
|
||||||
|
|
||||||
|
NSString *fragment = @"";
|
||||||
|
NSRange fragmentRange = [path rangeOfString:@"#"];
|
||||||
|
if (fragmentRange.location != NSNotFound)
|
||||||
|
{
|
||||||
|
fragmentRange = NSMakeRange(fragmentRange.location, [unixPath length] - fragmentRange.location);
|
||||||
|
|
||||||
|
fragment = [unixPath substringWithRange:fragmentRange];
|
||||||
|
[unixPath deleteCharactersInRange:fragmentRange];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (![unixPath hasPrefix:@"/"]) {
|
||||||
|
//Only relative paths would have windows backslashes.
|
||||||
|
[unixPath replaceOccurrencesOfString:@"\\" withString:@"/" options:0 range:NSMakeRange(0, [unixPath length])];
|
||||||
|
|
||||||
|
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
||||||
|
|
||||||
|
[unixPath insertString:basePath atIndex:0];
|
||||||
|
}
|
||||||
|
|
||||||
//Only relative paths would have windows backslashes.
|
//Append the fragment
|
||||||
[unixPath replaceOccurrencesOfString:@"\\" withString:@"/" options:0 range:NSMakeRange(0, [unixPath length])];
|
return [NSURL URLWithString:[[[NSURL fileURLWithPath:unixPath] absoluteString] stringByAppendingString: fragment]];
|
||||||
|
|
||||||
NSMutableString *urlString = [[NSMutableString alloc] init];
|
|
||||||
[urlString setString:@"file://"];
|
|
||||||
|
|
||||||
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
|
||||||
|
|
||||||
[urlString appendString:basePath];
|
|
||||||
[urlString appendString:unixPath];
|
|
||||||
|
|
||||||
[unixPath release];
|
|
||||||
|
|
||||||
NSURL *url = [NSURL URLWithString:urlString];
|
|
||||||
[urlString release];
|
|
||||||
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray *)urlsForContainerURL:(NSURL *)url
|
+ (NSArray *)urlsForContainerURL:(NSURL *)url
|
||||||
|
|
Loading…
Reference in a new issue