QTfrontend/util/platform/M3InstallController.m
changeset 8449 2816230a107e
parent 8440 ea4d6a7a2937
child 8931 ca678bee1a41
equal deleted inserted replaced
8447:250142acef7b 8449:2816230a107e
    68     NSString *userAppsPath = [[[NSString stringWithString:@"~/Applications"] stringByAppendingPathComponent:[[[NSBundle mainBundle] bundlePath] lastPathComponent]] stringByExpandingTildeInPath];
    68     NSString *userAppsPath = [[[NSString stringWithString:@"~/Applications"] stringByAppendingPathComponent:[[[NSBundle mainBundle] bundlePath] lastPathComponent]] stringByExpandingTildeInPath];
    69     NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
    69     NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
    70 
    70 
    71     //Delete the app that is installed
    71     //Delete the app that is installed
    72     if ([[NSFileManager defaultManager] fileExistsAtPath:appsPath]) {
    72     if ([[NSFileManager defaultManager] fileExistsAtPath:appsPath]) {
    73         [[NSFileManager defaultManager] removeFileAtPath:appsPath handler:nil];
    73         if ([NSFileManager instancesRespondToSelector:@selector(removeItemAtPath:error:)])
       
    74             [[NSFileManager defaultManager] removeItemAtPath:appsPath error:nil];
       
    75         else
       
    76             //casting hides the deprecation warning
       
    77             [(id)[NSFileManager defaultManager] removeFileAtPath:appsPath handler:nil];
    74     }
    78     }
    75     //Delete the app that is installed
    79     //Delete the app that is installed
    76     if ([[NSFileManager defaultManager] copyPath:[[NSBundle mainBundle] bundlePath] toPath:appsPath
    80     BOOL success = NO;
    77                                           handler:nil]) {
    81     if ([NSFileManager instancesRespondToSelector:@selector(copyItemAtPath:toPath:error:)])
       
    82         success = [[NSFileManager defaultManager] copyItemAtPath:[[NSBundle mainBundle] bundlePath]
       
    83                                                           toPath:appsPath
       
    84                                                            error:nil];
       
    85     else
       
    86         success = [(id)[NSFileManager defaultManager] copyPath:[[NSBundle mainBundle] bundlePath]
       
    87                                                         toPath:appsPath
       
    88                                                        handler:nil];
       
    89     if (success) {
    78         NSRunAlertPanel([NSString stringWithFormat:NSLocalizedString(@"%@ installed successfully", @"App Name installed successfully"), appName],
    90         NSRunAlertPanel([NSString stringWithFormat:NSLocalizedString(@"%@ installed successfully", @"App Name installed successfully"), appName],
    79                         [NSString stringWithFormat:NSLocalizedString(@"%@ was installed in /Applications", @"App Name was installed in /Applications"), appName],
    91                         [NSString stringWithFormat:NSLocalizedString(@"%@ was installed in /Applications", @"App Name was installed in /Applications"), appName],
    80                         NSLocalizedString(@"Quit", @"Quit"), nil, nil);
    92                         NSLocalizedString(@"Quit", @"Quit"), nil, nil);
    81     } else {
    93     } else {
    82         if ([[NSFileManager defaultManager] fileExistsAtPath:userAppsPath]) {
    94         if ([[NSFileManager defaultManager] fileExistsAtPath:userAppsPath]) {
    83             [[NSFileManager defaultManager] removeFileAtPath:userAppsPath handler:nil];
    95             if ([NSFileManager instancesRespondToSelector:@selector(removeItemAtPath:error:)])
       
    96                 [[NSFileManager defaultManager] removeItemAtPath:userAppsPath error:nil];
       
    97             else
       
    98                 [(id)[NSFileManager defaultManager] removeFileAtPath:userAppsPath handler:nil];
    84         }
    99         }
    85         if ([[NSFileManager defaultManager] copyPath:[[NSBundle mainBundle] bundlePath] toPath:userAppsPath
   100         if ([NSFileManager instancesRespondToSelector:@selector(copyItemAtPath:toPath:error:)])
    86                                                 handler:nil]) {
   101             success = [[NSFileManager defaultManager] copyItemAtPath:[[NSBundle mainBundle] bundlePath]
    87         NSRunAlertPanel([NSString stringWithFormat:NSLocalizedString(@"%@ installed successfully", @"AppName installed successfully"), appName],
   102                                                               toPath:userAppsPath
       
   103                                                                error:nil];
       
   104         else
       
   105             success = [(id)[NSFileManager defaultManager] copyPath:[[NSBundle mainBundle] bundlePath]
       
   106                                                             toPath:userAppsPath
       
   107                                                            handler:nil];
       
   108         if (success) {
       
   109             NSRunAlertPanel([NSString stringWithFormat:NSLocalizedString(@"%@ installed successfully", @"AppName installed successfully"), appName],
    88                 [NSString stringWithFormat:NSLocalizedString(@"%@ was installed in %@", @"App Name was installed in %@"), appName, [[NSString stringWithString:@"~/Applications"] stringByExpandingTildeInPath]],
   110                 [NSString stringWithFormat:NSLocalizedString(@"%@ was installed in %@", @"App Name was installed in %@"), appName, [[NSString stringWithString:@"~/Applications"] stringByExpandingTildeInPath]],
    89                         NSLocalizedString(@"Quit", @"Quit"), nil, nil);
   111                         NSLocalizedString(@"Quit", @"Quit"), nil, nil);
    90         } else {
   112         } else {
    91             NSRunAlertPanel([NSString stringWithFormat:NSLocalizedString(@"Could not install %@", @"Could not install App Name"), appName],
   113             NSRunAlertPanel([NSString stringWithFormat:NSLocalizedString(@"Could not install %@", @"Could not install App Name"), appName],
    92                             NSLocalizedString(@"An error occurred when installing", @"An error occurred when installing"), NSLocalizedString(@"Quit", @"Quit"), nil, nil);
   114                             NSLocalizedString(@"An error occurred when installing", @"An error occurred when installing"), NSLocalizedString(@"Quit", @"Quit"), nil, nil);