diff options
author | Damiano Galassi <[email protected]> | 2017-01-20 18:52:22 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2017-01-20 18:52:22 +0100 |
commit | a3d00959f42f940e8d3c2b73fb92a951cbf94472 (patch) | |
tree | 7085331974860d7771a3f6adaf1694383a1f064a /macosx/HBJobOutputFileWriter.m | |
parent | 40ec4ebaa2958b2549125dd525b6fcb2bd595d69 (diff) |
MacGui: initial sandbox support. Added two new scheme RELEASE-SANDBOX and DEBUG-SANDBOX to build HandBrake with sandbox enabled.
Diffstat (limited to 'macosx/HBJobOutputFileWriter.m')
-rw-r--r-- | macosx/HBJobOutputFileWriter.m | 33 |
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 |