summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
Diffstat (limited to 'macosx')
-rw-r--r--macosx/HBJobOutputFileWriter.h6
-rw-r--r--macosx/HBJobOutputFileWriter.m2
-rw-r--r--macosx/HBOutputFileWriter.h6
-rw-r--r--macosx/HBOutputFileWriter.m28
-rw-r--r--macosx/HBOutputRedirect.h3
5 files changed, 36 insertions, 9 deletions
diff --git a/macosx/HBJobOutputFileWriter.h b/macosx/HBJobOutputFileWriter.h
index b7dcdfaab..f5394ca47 100644
--- a/macosx/HBJobOutputFileWriter.h
+++ b/macosx/HBJobOutputFileWriter.h
@@ -6,6 +6,8 @@
#import "HBOutputFileWriter.h"
+NS_ASSUME_NONNULL_BEGIN
+
@class HBJob;
/**
@@ -14,6 +16,8 @@
*/
@interface HBJobOutputFileWriter : HBOutputFileWriter
-- (instancetype)initWithJob:(HBJob *)job NS_DESIGNATED_INITIALIZER;
+- (nullable instancetype)initWithJob:(HBJob *)job NS_DESIGNATED_INITIALIZER;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/macosx/HBJobOutputFileWriter.m b/macosx/HBJobOutputFileWriter.m
index fa84350ec..7f2f3d020 100644
--- a/macosx/HBJobOutputFileWriter.m
+++ b/macosx/HBJobOutputFileWriter.m
@@ -10,7 +10,7 @@
@implementation HBJobOutputFileWriter
-- (instancetype)initWithJob:(HBJob *)job
+- (nullable instancetype)initWithJob:(HBJob *)job
{
NSURL *outputURL= job.destURL;
diff --git a/macosx/HBOutputFileWriter.h b/macosx/HBOutputFileWriter.h
index 3538cc76e..a6e22680c 100644
--- a/macosx/HBOutputFileWriter.h
+++ b/macosx/HBOutputFileWriter.h
@@ -7,13 +7,15 @@
#import <Foundation/Foundation.h>
#import "HBOutputRedirect.h"
+NS_ASSUME_NONNULL_BEGIN
+
/**
* This class is used to listen to HBOutputRedirect
* and write the output to a file.
*/
@interface HBOutputFileWriter : NSObject <HBOutputRedirectListening>
-- (instancetype)initWithFileURL:(NSURL *)url;
+- (nullable instancetype)initWithFileURL:(NSURL *)url;
- (void)write:(NSString *)text;
- (void)clear;
@@ -21,3 +23,5 @@
@property (nonatomic, readonly) NSURL *url;
@end
+
+NS_ASSUME_NONNULL_END
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"];
}
diff --git a/macosx/HBOutputRedirect.h b/macosx/HBOutputRedirect.h
index f689b8795..2679051fd 100644
--- a/macosx/HBOutputRedirect.h
+++ b/macosx/HBOutputRedirect.h
@@ -7,6 +7,7 @@
#import <Foundation/Foundation.h>
+NS_ASSUME_NONNULL_BEGIN
@protocol HBOutputRedirectListening <NSObject>
@@ -35,3 +36,5 @@
- (void)removeListener:(id <HBOutputRedirectListening>)aListener;
@end
+
+NS_ASSUME_NONNULL_END