Commit f7374647 authored by Felix Paul Kühne's avatar Felix Paul Kühne

URL handling: add error handling and behave correctly when saving files

parent 10c9d0e9
......@@ -43,7 +43,7 @@
if (_playlistViewController && url != nil) {
APLog(@"%@ requested %@ to be opened", sourceApplication, url);
if (url.isFileURL || [url.scheme isEqualToString:@"http"] || [url.scheme isEqualToString:@"https"]) {
if (url.isFileURL) {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"SAVE_FILE", @"") message:[NSString stringWithFormat:NSLocalizedString(@"SAVE_FILE_LONG", @""), url.lastPathComponent] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", @"") otherButtonTitles:NSLocalizedString(@"BUTTON_SAVE", @""), nil];
_tempURL = url;
[alert show];
......@@ -59,14 +59,15 @@
if (buttonIndex == 1) {
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *directoryPath = searchPaths[0];
NSURL *destinationURL = [NSURL URLWithString:[NSString stringWithFormat:@"file://%@/%@", directoryPath, _tempURL.lastPathComponent]];
NSURL *destinationURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@", directoryPath, _tempURL.lastPathComponent]];
NSError *theError;
[[NSFileManager defaultManager] copyItemAtURL:_tempURL toURL:destinationURL error:&theError];
if (theError.code != noErr)
APLog(@"saving the file failed (%i): %@", theError.code, theError.localizedDescription);
[self updateMediaList];
}
[_playlistViewController openMovieFromURL:_tempURL];
} else
[_playlistViewController openMovieFromURL:_tempURL];
}
- (void)applicationWillResignActive:(UIApplication *)application
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment