Preview and Quicklook stubs

This commit is contained in:
michael starke
2014-03-18 21:42:56 +01:00
parent 6a28d03801
commit 34ba9f0575
8 changed files with 182 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
;//
// MPTemporaryFileStorage.m
// MacPass
//
// Created by Michael Starke on 18/03/14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import "MPTemporaryFileStorage.h"
#import "KPKBinary.h"
#import <QuickLook/QuickLook.h>
@interface MPTemporaryFileStorage ()
@property (strong) KPKBinary *binary;
@end
@implementation MPTemporaryFileStorage
- (instancetype)initWithBinary:(KPKBinary *)binary {
self = [super init];
if(self) {
_binary = binary;
}
return self;
}
- (void)quicklook {
NSString *fileName = [NSString stringWithFormat:@"%@_%@", [[NSProcessInfo processInfo] globallyUniqueString], self.binary.name];
NSURL *fileURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:fileName]];
NSError *error;
BOOL success = [self.binary.data writeToURL:fileURL options:0 error:&error];
if(!success) {
if(error) {
[NSApp presentError:error];
}
return;
}
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"srm"];
[task setArguments:@[@"-m", fileName]];
}
@end