diff options
author | ritsuka <[email protected]> | 2015-07-03 18:57:44 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2015-07-03 18:57:44 +0000 |
commit | d6b6e3f7d55033124964f092ba3170685b3b68ee (patch) | |
tree | b27ff480d8b309ba965ede8d893c458b76fad034 /macosx | |
parent | ce61c1e878d59d7114e2e3781622d5c08c4659bd (diff) |
MacGui: check if the log file can be written or not in HBOutputFileWriter init.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7335 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/HBJobOutputFileWriter.h | 6 | ||||
-rw-r--r-- | macosx/HBJobOutputFileWriter.m | 2 | ||||
-rw-r--r-- | macosx/HBOutputFileWriter.h | 6 | ||||
-rw-r--r-- | macosx/HBOutputFileWriter.m | 28 | ||||
-rw-r--r-- | macosx/HBOutputRedirect.h | 3 |
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 |