// ===== CFDate ===== func convertTimeToCFDate(t time.Time) C.CFDateRef { // truncate to milliseconds, to get a more predictable conversion ms := int64(time.Duration(t.UnixNano()) / time.Millisecond * time.Millisecond) nano := C.double(ms) / C.double(time.Second) nano -= C.kCFAbsoluteTimeIntervalSince1970 return C.CFDateCreate(nil, C.CFAbsoluteTime(nano)) }
// EventIDForDeviceBeforeTime returns an event ID before a given time. func EventIDForDeviceBeforeTime(dev int32, before time.Time) uint64 { tm := C.CFAbsoluteTime(before.Unix()) return uint64(C.FSEventsGetLastEventIdForDeviceBeforeTime(C.dev_t(dev), tm)) }
// https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/Reference/reference.html#jumpTo_5 func LastEventBefore(dev Device, ts time.Time) EventID { return EventID( C.FSEventsGetLastEventIdForDeviceBeforeTime( C.dev_t(dev), C.CFAbsoluteTime(ts.Unix()))) }