Fix another stupid crash.

This commit is contained in:
Damiano Galassi committed 2014-11-07 16:21:43 +01:00
1 parent 2e72d6d8ba
commit 7111fa4d4f
2 files changed
+12 -2

No files matched your search

+10 -2
View File
@@ -26,9 +26,17 @@
[SBPrefsController registerUserDefaults]; [SBPrefsController registerUserDefaults];
NSString *path = [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSString *appSupportPath = [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
NSUserDomainMask, NSUserDomainMask,
YES) firstObject] stringByAppendingPathComponent:@"Subler/debugLog.txt"]; YES) firstObject] stringByAppendingPathComponent:@"Subler"];
if (![[NSFileManager defaultManager] fileExistsAtPath:appSupportPath]) {
[[NSFileManager defaultManager] createDirectoryAtPath:appSupportPath withIntermediateDirectories:YES attributes:nil error:NULL];
}
NSString *path = [appSupportPath stringByAppendingPathComponent:@"debugLog.txt"];
SBLogger *logger = [[SBLogger alloc] initWithLogFile:[NSURL fileURLWithPath:path]]; SBLogger *logger = [[SBLogger alloc] initWithLogFile:[NSURL fileURLWithPath:path]];
[logger clearLog]; [logger clearLog];
+2
View File
@@ -43,9 +43,11 @@
- (void)writeToLog:(NSString *)string { - (void)writeToLog:(NSString *)string {
if (self.fileURL) { if (self.fileURL) {
FILE *f = fopen([[self.fileURL path] fileSystemRepresentation], "a"); FILE *f = fopen([[self.fileURL path] fileSystemRepresentation], "a");
if (f) {
fprintf(f, "%s %s", [[self currentTime] UTF8String], [string UTF8String]); fprintf(f, "%s %s", [[self currentTime] UTF8String], [string UTF8String]);
fclose(f); fclose(f);
} }
}
if (self.delegate) { if (self.delegate) {
[self.delegate writeToLog:[NSString stringWithFormat:@"%@ %@", [self currentTime], string]]; [self.delegate writeToLog:[NSString stringWithFormat:@"%@ %@", [self currentTime], string]];