summaryrefslogtreecommitdiffstats
path: root/macosx/HBSecurityAccessToken.m
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/HBSecurityAccessToken.m')
-rw-r--r--macosx/HBSecurityAccessToken.m42
1 files changed, 42 insertions, 0 deletions
diff --git a/macosx/HBSecurityAccessToken.m b/macosx/HBSecurityAccessToken.m
new file mode 100644
index 000000000..027f66920
--- /dev/null
+++ b/macosx/HBSecurityAccessToken.m
@@ -0,0 +1,42 @@
+//
+// HBSecurityAccessToken.m
+// HandBrake
+//
+// Created by Damiano Galassi on 24/01/17.
+//
+//
+
+#import "HBSecurityAccessToken.h"
+
+@interface HBSecurityAccessToken ()
+@property (nonatomic, readonly) id<HBSecurityScope> object;
+@property (nonatomic, readonly) BOOL accessed;
+@end
+
+@implementation HBSecurityAccessToken
+
+- (instancetype)initWithObject:(id<HBSecurityScope>)object;
+{
+ self = [super init];
+ if (self)
+ {
+ _object = object;
+ _accessed = [_object startAccessingSecurityScopedResource];
+ }
+ return self;
+}
+
++ (instancetype)tokenWithObject:(id<HBSecurityScope>)object
+{
+ return [[self alloc] initWithObject:object];
+}
+
+- (void)dealloc
+{
+ if (_accessed)
+ {
+ [_object stopAccessingSecurityScopedResource];
+ }
+}
+
+@end