Fix AdPlug fileprovider to handle URL fragments properly.

CQTexperiment
Christopher Snowhill 2019-07-07 00:38:19 -07:00
parent c1a45135b3
commit b5b4eaf99d
1 changed files with 7 additions and 1 deletions

View File

@ -94,7 +94,13 @@ binistream * CProvider_cog::open(std::string filename) const
if ( p_file == nil ) if ( p_file == nil )
{ {
NSString * urlString = [NSString stringWithUTF8String:filename.c_str()]; NSString * urlString = [NSString stringWithUTF8String:filename.c_str()];
NSURL * url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSString * fragmentString = @"";
NSRange fragmentRange = [urlString rangeOfString:@"#" options:NSBackwardsSearch];
if (fragmentRange.location != NSNotFound) {
fragmentString = [urlString substringFromIndex:fragmentRange.location];
urlString = [urlString substringToIndex:fragmentRange.location];
}
NSURL * url = [NSURL URLWithString:[[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByAppendingString:fragmentString]];
id audioSourceClass = NSClassFromString(@"AudioSource"); id audioSourceClass = NSClassFromString(@"AudioSource");
p_file = [audioSourceClass audioSourceForURL:url]; p_file = [audioSourceClass audioSourceForURL:url];