github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/chat/attachments/quarantine_darwin.go (about) 1 //go:build darwin && !ios 2 // +build darwin,!ios 3 4 package attachments 5 6 /* 7 #cgo CFLAGS: -x objective-c -fobjc-arc 8 #include <Foundation/Foundation.h> 9 void quarantineFile(const char* inFilename) { 10 NSError* error = NULL; 11 NSString* filename = [NSString stringWithUTF8String:inFilename]; 12 NSURL* url = [NSURL fileURLWithPath:filename]; 13 NSDictionary* opts = [[NSDictionary alloc] initWithObjectsAndKeys: 14 (id)@"Keybase", (id)kLSQuarantineAgentNameKey, 15 (id)kLSQuarantineTypeOtherDownload, (id)kLSQuarantineTypeKey, 16 nil]; 17 [url setResourceValue:opts forKey:NSURLQuarantinePropertiesKey error:&error]; 18 } 19 */ 20 import "C" 21 import ( 22 "unsafe" 23 24 "golang.org/x/net/context" 25 ) 26 27 func Quarantine(ctx context.Context, path string) error { 28 cpath := C.CString(path) 29 defer C.free(unsafe.Pointer(cpath)) 30 C.quarantineFile(cpath) 31 return nil 32 }