| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "Unpacker.h" | 5 #import "Unpacker.h" |
| 6 | 6 |
| 7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
| 8 #include <DiskArbitration/DiskArbitration.h> | 8 #include <DiskArbitration/DiskArbitration.h> |
| 9 #include <dispatch/dispatch.h> | 9 #include <dispatch/dispatch.h> |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 @implementation Unpacker | 44 @implementation Unpacker |
| 45 | 45 |
| 46 @synthesize delegate = delegate_; | 46 @synthesize delegate = delegate_; |
| 47 @synthesize appPath = appPath_; | 47 @synthesize appPath = appPath_; |
| 48 | 48 |
| 49 - (void)cleanUp { | 49 - (void)cleanUp { |
| 50 [mountTask_ terminate]; | 50 [mountTask_ terminate]; |
| 51 // It's not the end of the world if this temporary directory is not removed | 51 // It's not the end of the world if this temporary directory is not removed |
| 52 // here. It will be deleted when the operating system itself decides to | 52 // here. The directory will be deleted when the operating system itself |
| 53 // anyway. | 53 // decides to anyway. |
| 54 [[NSFileManager defaultManager] removeItemAtURL:temporaryDirectoryURL_ | 54 [[NSFileManager defaultManager] removeItemAtURL:temporaryDirectoryURL_ |
| 55 error:nil]; | 55 error:nil]; |
| 56 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 56 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 57 } | 57 } |
| 58 | 58 |
| 59 // TODO: the failure delegate methods need to be revised to be more meaningfully | 59 // TODO: The failure delegate methods need to be revised to meaningfully deal |
| 60 // deal with the errors (pipe in stderr / stdout) | 60 // with the errors (pipe in stderr / stdout to handle the error according to |
| 61 // what the error was). |
| 61 - (void)mountDMGFromURL:(NSURL*)fileURL { | 62 - (void)mountDMGFromURL:(NSURL*)fileURL { |
| 62 NSError* error = nil; | 63 NSError* error = nil; |
| 63 temporaryDirectoryURL_ = [[NSFileManager defaultManager] | 64 temporaryDirectoryURL_ = [[NSFileManager defaultManager] |
| 64 URLForDirectory:NSItemReplacementDirectory | 65 URLForDirectory:NSItemReplacementDirectory |
| 65 inDomain:NSUserDomainMask | 66 inDomain:NSUserDomainMask |
| 66 appropriateForURL:[NSURL fileURLWithPath:@"/" isDirectory:YES] | 67 appropriateForURL:[NSURL fileURLWithPath:@"/" isDirectory:YES] |
| 67 create:YES | 68 create:YES |
| 68 error:&error]; | 69 error:&error]; |
| 69 if (error) { | 70 if (error) { |
| 70 [delegate_ unpacker:self onMountFailure:error]; | 71 [delegate_ unpacker:self onMountFailure:error]; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 (__bridge NSString*)DADissenterGetStatusString(dissenter) | 159 (__bridge NSString*)DADissenterGetStatusString(dissenter) |
| 159 }]; | 160 }]; |
| 160 [delegate_ unpacker:self onUnmountFailure:error]; | 161 [delegate_ unpacker:self onUnmountFailure:error]; |
| 161 } else { | 162 } else { |
| 162 [self cleanUp]; | 163 [self cleanUp]; |
| 163 [delegate_ unpacker:self onUnmountSuccess:mountPath_]; | 164 [delegate_ unpacker:self onUnmountSuccess:mountPath_]; |
| 164 } | 165 } |
| 165 } | 166 } |
| 166 | 167 |
| 167 @end | 168 @end |
| OLD | NEW |