Adding quarantine attributes to downloaded files.

svn path=/trunk/netsurf/; revision=12429
This commit is contained in:
Sven Weidauer 2011-05-19 07:27:21 +00:00
parent ae46764ec4
commit eb0570f39d
1 changed files with 12 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#import "desktop/download.h"
#import "desktop/gui.h"
#import "utils/log.h"
@interface DownloadWindowController ()
@ -103,6 +104,17 @@ static void cocoa_register_download( DownloadWindowController *download );
NSString *path = [targetURL path];
[[NSFileManager defaultManager] createFileAtPath: path contents: nil attributes: nil];
FSRef ref;
if (CFURLGetFSRef( (CFURLRef)targetURL, &ref )) {
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
url, (NSString *)kLSQuarantineDataURLKey,
(NSString *)kLSQuarantineTypeWebDownload, (NSString *)kLSQuarantineTypeKey,
nil];
LSSetItemAttribute( &ref, kLSRolesAll, kLSItemQuarantineProperties, (CFDictionaryRef)attributes );
LOG(("Set quarantine attributes on file %s", [path UTF8String]));
}
[self setOutputFile: [NSFileHandle fileHandleForWritingAtPath: path]];
[self setSaveURL: targetURL];