Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/mac_osx2/src/external/cmcrashreporter/CMCrashReporter.m @ 8356

Last change on this file since 8356 was 8356, checked in by rgrieder, 13 years ago

Merged remaining revisions in mac_osx to mac_osx2 branch.

File size: 1.6 KB
Line 
1//
2//  CMCrashReporter.m
3//  CMCrashReporter-App
4//
5//  Created by Jelle De Laender on 20/01/08.
6//  Copyright 2008 CodingMammoth. All rights reserved.
7//  Copyright 2010 CodingMammoth. Revision. All rights reserved.
8//
9
10#import "CMCrashReporter.h"
11
12@implementation CMCrashReporter
13
14+(void)check
15{
16        NSUserDefaults *defaults = [[NSUserDefaultsController sharedUserDefaultsController] defaults];
17        if ([CMCrashReporterGlobal checkOnCrashes] && ![defaults boolForKey:@"CMCrashReporterIgnoreCrashes"]) {
18                NSArray *reports = [self getReports];
19                if ([reports count] > 0) {
20                        [CMCrashReporterWindow runCrashReporterWithPaths:reports];
21                }
22        }
23}
24
25+(NSArray *)getReports
26{
27        NSFileManager *fileManager = [NSFileManager defaultManager];
28       
29        if ([CMCrashReporterGlobal isRunningLeopard]) {
30                // (Snow) Leopard format is AppName_Year_Month_Day
31                NSString *file;
32                NSString *path = [@"~/Library/Logs/CrashReporter/" stringByExpandingTildeInPath];
33                NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:path];
34
35                NSMutableArray *array = [NSMutableArray array];
36                while (file = [dirEnum nextObject])
37                        if ([file hasPrefix:[CMCrashReporterGlobal appName]])
38                                [array addObject:[[NSString stringWithFormat:@"~/Library/Logs/CrashReporter/%@",file] stringByExpandingTildeInPath]];
39               
40                return array;
41        } else {
42                // Tiger Format is AppName.crash.log
43                NSString *path = [[NSString stringWithFormat:@"~/Library/Logs/CrashReporter/%@.crash.log",[CMCrashReporterGlobal appName]] stringByExpandingTildeInPath];
44                if ([fileManager fileExistsAtPath:path]) return [NSArray arrayWithObject:path];
45                else return nil;
46        }
47}
48@end
Note: See TracBrowser for help on using the repository browser.