Bug fixes for playlist file loading.

CQTexperiment
vspader 2007-10-19 03:06:52 +00:00
parent d82fdcbf62
commit 16f0c942bc
3 changed files with 43 additions and 15 deletions

View File

@ -26,13 +26,22 @@
NSMutableString *unixPath = [path mutableCopy]; NSMutableString *unixPath = [path mutableCopy];
//Get the fragment
NSString *fragment = @""; NSString *fragment = @"";
NSRange fragmentRange = [path rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"#0123456789"] options:(NSAnchoredSearch | NSBackwardsSearch)]; NSScanner *scanner = [NSScanner scannerWithString:unixPath];
if (fragmentRange.location != NSNotFound) NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:@"#1234567890"];
while (![scanner isAtEnd]) {
NSString *possibleFragment;
[scanner scanUpToString:@"#" intoString:nil];
if ([scanner scanCharactersFromSet:characterSet intoString:&possibleFragment] && [scanner isAtEnd])
{ {
fragment = [unixPath substringWithRange:fragmentRange]; fragment = possibleFragment;
[unixPath deleteCharactersInRange:fragmentRange]; [unixPath deleteCharactersInRange:NSMakeRange([scanner scanLocation] - [possibleFragment length], [possibleFragment length])];
break;
} }
}
NSLog(@"Fragment: %@", fragment);
if (![unixPath hasPrefix:@"/"]) { if (![unixPath hasPrefix:@"/"]) {
//Only relative paths would have windows backslashes. //Only relative paths would have windows backslashes.
@ -49,6 +58,7 @@
- (void)parseFile:(NSString *)filename - (void)parseFile:(NSString *)filename
{ {
NSError *error = nil; NSError *error = nil;

View File

@ -31,13 +31,22 @@
NSMutableString *unixPath = [path mutableCopy]; NSMutableString *unixPath = [path mutableCopy];
//Get the fragment
NSString *fragment = @""; NSString *fragment = @"";
NSRange fragmentRange = [path rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"#0123456789"] options:(NSAnchoredSearch | NSBackwardsSearch)]; NSScanner *scanner = [NSScanner scannerWithString:unixPath];
if (fragmentRange.location != NSNotFound) NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:@"#1234567890"];
while (![scanner isAtEnd]) {
NSString *possibleFragment;
[scanner scanUpToString:@"#" intoString:nil];
if ([scanner scanCharactersFromSet:characterSet intoString:&possibleFragment] && [scanner isAtEnd])
{ {
fragment = [unixPath substringWithRange:fragmentRange]; fragment = possibleFragment;
[unixPath deleteCharactersInRange:fragmentRange]; [unixPath deleteCharactersInRange:NSMakeRange([scanner scanLocation] - [possibleFragment length], [possibleFragment length])];
break;
} }
}
NSLog(@"Fragment: %@", fragment);
if (![unixPath hasPrefix:@"/"]) { if (![unixPath hasPrefix:@"/"]) {
//Only relative paths would have windows backslashes. //Only relative paths would have windows backslashes.

View File

@ -31,13 +31,22 @@
NSMutableString *unixPath = [path mutableCopy]; NSMutableString *unixPath = [path mutableCopy];
//Get the fragment
NSString *fragment = @""; NSString *fragment = @"";
NSRange fragmentRange = [path rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"#0123456789"] options:(NSAnchoredSearch | NSBackwardsSearch)]; NSScanner *scanner = [NSScanner scannerWithString:unixPath];
if (fragmentRange.location != NSNotFound) NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:@"#1234567890"];
while (![scanner isAtEnd]) {
NSString *possibleFragment;
[scanner scanUpToString:@"#" intoString:nil];
if ([scanner scanCharactersFromSet:characterSet intoString:&possibleFragment] && [scanner isAtEnd])
{ {
fragment = [unixPath substringWithRange:fragmentRange]; fragment = possibleFragment;
[unixPath deleteCharactersInRange:fragmentRange]; [unixPath deleteCharactersInRange:NSMakeRange([scanner scanLocation] - [possibleFragment length], [possibleFragment length])];
break;
} }
}
NSLog(@"Fragment: %@", fragment);
if (![unixPath hasPrefix:@"/"]) { if (![unixPath hasPrefix:@"/"]) {
//Only relative paths would have windows backslashes. //Only relative paths would have windows backslashes.