summaryrefslogtreecommitdiffstats
path: root/macosx/HBOutputFileWriter.m
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/HBOutputFileWriter.m')
-rw-r--r--macosx/HBOutputFileWriter.m28
1 files changed, 22 insertions, 6 deletions
diff --git a/macosx/HBOutputFileWriter.m b/macosx/HBOutputFileWriter.m
index 27ac917c5..fffe9478b 100644
--- a/macosx/HBOutputFileWriter.m
+++ b/macosx/HBOutputFileWriter.m
@@ -12,20 +12,36 @@
FILE *f;
}
-- (instancetype)initWithFileURL:(NSURL *)url;
+- (nullable instancetype)initWithFileURL:(NSURL *)url;
{
self = [super init];
if (self)
{
-
- [[NSFileManager defaultManager] createDirectoryAtPath:url.URLByDeletingLastPathComponent.path
- withIntermediateDirectories:YES
- attributes:nil
- error:NULL];
+ NSError *error;
+ BOOL result;
+ result = [[NSFileManager defaultManager] createDirectoryAtPath:url.URLByDeletingLastPathComponent.path
+ withIntermediateDirectories:YES
+ attributes:nil
+ error:&error];
+ if (!result)
+ {
+ [HBUtilities writeToActivityLog:"Error: coudln't open activity log file, %@", error];
+ return nil;
+ }
_url = [url copy];
+
f = fopen(url.path.fileSystemRepresentation, "w");
+ if (!f)
+ {
+ return nil;
+ }
+
f = freopen(NULL, "a", f);
+ if (!f)
+ {
+ return nil;
+ }
[self writeHeaderForReason:@"Session"];
}