summaryrefslogtreecommitdiffstats
path: root/macosx/HBJobOutputFileWriter.m
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/HBJobOutputFileWriter.m')
-rw-r--r--macosx/HBJobOutputFileWriter.m33
1 files changed, 28 insertions, 5 deletions
diff --git a/macosx/HBJobOutputFileWriter.m b/macosx/HBJobOutputFileWriter.m
index 7f2f3d020..f0641eac3 100644
--- a/macosx/HBJobOutputFileWriter.m
+++ b/macosx/HBJobOutputFileWriter.m
@@ -8,12 +8,17 @@
#import "HBJob.h"
#import "HBUtilities.h"
+@interface HBJobOutputFileWriter ()
+
+@property (nonatomic, readonly) NSURL *outputFolderURL;
+@property (nonatomic, readwrite) BOOL accessingSecurityScopedFile;
+
+@end
+
@implementation HBJobOutputFileWriter
- (nullable instancetype)initWithJob:(HBJob *)job
{
- NSURL *outputURL= job.destURL;
-
// Establish the log file location to write to.
// We need to get the current time in YY-MM-DD HH-MM-SS format to put at the beginning of the name of the log file
time_t _now = time(NULL);
@@ -26,13 +31,21 @@
// Assemble the new log file name as YY-MM-DD HH-MM-SS mymoviename.txt
NSString *outputDateFileName = [NSString stringWithFormat:@"%@ %@.txt",
- outputURL.lastPathComponent.stringByDeletingPathExtension,
+ job.outputFileName.stringByDeletingPathExtension,
dateForLogTitle];
+ NSURL *outputURL = nil;
+
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"EncodeLogLocation"])
{
// if we are putting it in the same directory with the movie
- outputURL = [outputURL.URLByDeletingLastPathComponent URLByAppendingPathComponent:outputDateFileName];
+ outputURL = [job.outputURL URLByAppendingPathComponent:outputDateFileName];
+
+#ifdef __SANDBOX_ENABLED__
+ _outputFolderURL = job.outputURL;
+ _accessingSecurityScopedFile = [_outputFolderURL startAccessingSecurityScopedResource];
+#endif
+
}
else
{
@@ -45,7 +58,7 @@
if (self)
{
// Additional header info.
- [self write:job.destURL.lastPathComponent];
+ [self write:job.outputFileName];
[self write:@"\nPreset: "];
[self write:job.presetName];
[self write:@"\n"];
@@ -54,4 +67,14 @@
return self;
}
+- (void)dealloc
+{
+#ifdef __SANDBOX_ENABLED__
+ if (_accessingSecurityScopedFile)
+ {
+ [_outputFolderURL.URLByDeletingLastPathComponent stopAccessingSecurityScopedResource];
+ }
+#endif
+}
+
@end