summaryrefslogtreecommitdiffstats
path: root/macosx/HBOutputFileWriter.m
diff options
context:
space:
mode:
authorritsuka <[email protected]>2015-07-03 18:57:44 +0000
committerritsuka <[email protected]>2015-07-03 18:57:44 +0000
commitd6b6e3f7d55033124964f092ba3170685b3b68ee (patch)
treeb27ff480d8b309ba965ede8d893c458b76fad034 /macosx/HBOutputFileWriter.m
parentce61c1e878d59d7114e2e3781622d5c08c4659bd (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/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"];
}