[vlc-devel] commit: macosx: Fix crashlog opening. (Pierre d'Herbemont )

git version control git at videolan.org
Sat Aug 2 00:23:42 CEST 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Fri Aug  1 23:22:02 2008 +0200| [6903d514d3ea8113f91b1bedde862607f7efc92a] | committer: Pierre d'Herbemont 

macosx: Fix crashlog opening.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6903d514d3ea8113f91b1bedde862607f7efc92a
---

 modules/gui/macosx/intf.m |   41 +++++++++++++++++++++++++++++++++++------
 1 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 17b163f..a54c34c 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1991,14 +1991,43 @@ end:
 
 - (IBAction)openCrashLog:(id)sender
 {
-    NSString * o_path = [@"~/Library/Logs/CrashReporter/VLC.crash.log"
-                                    stringByExpandingTildeInPath];
-
+    NSString * crashReporter = [@"~/Library/Logs/CrashReporter" stringByExpandingTildeInPath];
+    NSDirectoryEnumerator *direnum = [[NSFileManager defaultManager] enumeratorAtPath:crashReporter];
+    NSString *fname;
+    BOOL found = NO;
+    NSString * latestLog = nil;
+    int year = 0;
+    int month = 0;
+    int day = 0;
+    int hours = 0;
+
+    while (fname = [direnum nextObject])
+    {
+        [direnum skipDescendents];
+        if([fname hasPrefix:@"VLC"] && [fname hasSuffix:@"crash"])
+        {
+            NSArray * compo = [fname componentsSeparatedByString:@"_"];
+            if( [compo count] < 3 ) { found = NO; break; }
+            compo = [[compo objectAtIndex:1] componentsSeparatedByString:@"-"];
+            if( [compo count] < 4 ) { found = NO; break; }
+            if( year  < [[compo objectAtIndex:0] intValue] &&
+                month < [[compo objectAtIndex:1] intValue] &&
+                day   < [[compo objectAtIndex:2] intValue] &&
+                hours < [[compo objectAtIndex:3] intValue] )
+            {
+                year  = [[compo objectAtIndex:0] intValue];
+                month = [[compo objectAtIndex:1] intValue];
+                day   = [[compo objectAtIndex:2] intValue];
+                hours = [[compo objectAtIndex:3] intValue];
+                latestLog = [NSString stringWithFormat:@"%@/%@",crashReporter, fname];
+                found = YES;
+            }
+        }
+    }
 
-    if( [[NSFileManager defaultManager] fileExistsAtPath: o_path ] )
+    if( found && latestLog && [[NSFileManager defaultManager] fileExistsAtPath: latestLog ] )
     {
-        [[NSWorkspace sharedWorkspace] openFile: o_path
-                                    withApplication: @"Console"];
+        [[NSWorkspace sharedWorkspace] openFile: latestLog withApplication: @"Console"];
     }
     else
     {




More information about the vlc-devel mailing list