fsevent-sys-3.0.0/.gitignore010064400007650000024000000000521324303307000141770ustar0000000000000000# Generated by Cargo /target/ Cargo.lock fsevent-sys-3.0.0/Cargo.toml.orig010064400007650000024000000004721353673515200151230ustar0000000000000000[package] name = "fsevent-sys" version = "3.0.0" authors = ["Pierre Baillet "] description = "Rust bindings to the fsevent macOS API for file changes notifications" license = "MIT" repository = "https://github.com/octplane/fsevent-rust/tree/master/fsevent-sys" [dependencies] libc = "0.2.20" fsevent-sys-3.0.0/Cargo.toml0000644000000015160000000000000113620ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] name = "fsevent-sys" version = "3.0.0" authors = ["Pierre Baillet "] description = "Rust bindings to the fsevent macOS API for file changes notifications" license = "MIT" repository = "https://github.com/octplane/fsevent-rust/tree/master/fsevent-sys" [dependencies.libc] version = "0.2.20" fsevent-sys-3.0.0/LICENSE010064400007650000024000000020721245521212400132230ustar0000000000000000The MIT License (MIT) Copyright (c) 2015 Pierre Baillet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. fsevent-sys-3.0.0/src/core_foundation.rs010064400007650000024000000152421353651740200165440ustar0000000000000000#![allow(non_upper_case_globals, non_camel_case_types)] extern crate libc; use std::ffi::CString; use std::ptr; use std::str; pub type Boolean = std::os::raw::c_uchar; pub type CFRef = *mut ::std::os::raw::c_void; pub type CFIndex = ::std::os::raw::c_long; pub type CFTimeInterval = f64; #[doc(hidden)] pub enum CFError {} pub type CFAllocatorRef = CFRef; pub type CFMutableArrayRef = CFRef; pub type CFURLRef = CFRef; pub type CFErrorRef = *mut CFError; pub type CFStringRef = CFRef; pub type CFRunLoopRef = CFRef; pub const NULL: CFRef = 0 as CFRef; pub const NULL_REF_PTR: *mut CFRef = 0 as *mut CFRef; pub type CFAllocatorRetainCallBack = extern "C" fn(*const std::os::raw::c_void) -> *const std::os::raw::c_void; pub type CFAllocatorReleaseCallBack = extern "C" fn(*const std::os::raw::c_void); pub type CFAllocatorCopyDescriptionCallBack = extern "C" fn(*const std::os::raw::c_void) -> *const CFStringRef; pub type CFURLPathStyle = CFIndex; pub const kCFAllocatorDefault: CFAllocatorRef = NULL; pub const kCFURLPOSIXPathStyle: CFURLPathStyle = 0; pub const kCFURLHFSPathStyle: CFURLPathStyle = 1; pub const kCFURLWindowsPathStyle: CFURLPathStyle = 2; pub const kCFStringEncodingUTF8: CFStringEncoding = 0x08000100; pub type CFStringEncoding = u32; pub const kCFCompareEqualTo: CFIndex = 0; pub type CFComparisonResult = CFIndex; // MacOS uses Case Insensitive path pub const kCFCompareCaseInsensitive: CFStringCompareFlags = 1; pub type CFStringCompareFlags = std::os::raw::c_ulong; pub type CFArrayRetainCallBack = extern "C" fn(CFAllocatorRef, *const std::os::raw::c_void) -> *const std::os::raw::c_void; pub type CFArrayReleaseCallBack = extern "C" fn(CFAllocatorRef, *const std::os::raw::c_void); pub type CFArrayCopyDescriptionCallBack = extern "C" fn(*const std::os::raw::c_void) -> CFStringRef; pub type CFArrayEqualCallBack = extern "C" fn(*const std::os::raw::c_void, *const std::os::raw::c_void) -> Boolean; #[repr(C)] pub struct CFArrayCallBacks { version: CFIndex, retain: Option, release: Option, cp: Option, equal: Option, } //impl Clone for CFArrayCallBacks { } #[link(name = "CoreServices", kind = "framework")] extern "C" { pub static kCFTypeArrayCallBacks: CFArrayCallBacks; pub static kCFRunLoopDefaultMode: CFStringRef; pub fn CFRelease(res: CFRef); pub fn CFShow(res: CFRef); pub fn CFCopyDescription(cf: CFRef) -> CFStringRef; pub fn CFRunLoopRun(); pub fn CFRunLoopStop(run_loop: CFRunLoopRef); pub fn CFRunLoopGetCurrent() -> CFRunLoopRef; pub fn CFArrayCreateMutable( allocator: CFRef, capacity: CFIndex, callbacks: *const CFArrayCallBacks, ) -> CFMutableArrayRef; pub fn CFArrayInsertValueAtIndex(arr: CFMutableArrayRef, position: CFIndex, element: CFRef); pub fn CFArrayAppendValue(aff: CFMutableArrayRef, element: CFRef); pub fn CFArrayGetCount(arr: CFMutableArrayRef) -> CFIndex; pub fn CFArrayGetValueAtIndex(arr: CFMutableArrayRef, index: CFIndex) -> CFRef; pub fn CFURLCreateFileReferenceURL( allocator: CFRef, url: CFURLRef, err: *mut CFErrorRef, ) -> CFURLRef; pub fn CFURLCreateFilePathURL( allocator: CFRef, url: CFURLRef, err: *mut CFErrorRef, ) -> CFURLRef; pub fn CFURLCreateFromFileSystemRepresentation( allocator: CFRef, path: *const ::std::os::raw::c_char, len: CFIndex, is_directory: bool, ) -> CFURLRef; pub fn CFURLCopyAbsoluteURL(res: CFURLRef) -> CFURLRef; pub fn CFURLCopyLastPathComponent(res: CFURLRef) -> CFStringRef; pub fn CFURLCreateCopyDeletingLastPathComponent(allocator: CFRef, url: CFURLRef) -> CFURLRef; pub fn CFURLCreateCopyAppendingPathComponent( allocation: CFRef, url: CFURLRef, path: CFStringRef, is_directory: bool, ) -> CFURLRef; pub fn CFURLCopyFileSystemPath(anUrl: CFURLRef, path_style: CFURLPathStyle) -> CFStringRef; pub fn CFURLResourceIsReachable(res: CFURLRef, err: *mut CFErrorRef) -> bool; pub fn CFShowStr(str: CFStringRef); pub fn CFStringGetCString( theString: CFStringRef, buffer: *mut ::std::os::raw::c_char, buffer_size: CFIndex, encoding: CFStringEncoding, ) -> bool; pub fn CFStringGetCStringPtr( theString: CFStringRef, encoding: CFStringEncoding, ) -> *const ::std::os::raw::c_char; pub fn CFStringCreateWithCString( alloc: CFRef, source: *const ::std::os::raw::c_char, encoding: CFStringEncoding, ) -> CFStringRef; pub fn CFStringCompare( theString1: CFStringRef, theString2: CFStringRef, compareOptions: CFStringCompareFlags, ) -> CFComparisonResult; pub fn CFArrayRemoveValueAtIndex(theArray: CFMutableArrayRef, idx: CFIndex); } pub unsafe fn str_path_to_cfstring_ref(source: &str, err: &mut CFErrorRef) -> CFStringRef { let c_path = CString::new(source).unwrap(); let c_len = libc::strlen(c_path.as_ptr()); let mut url = CFURLCreateFromFileSystemRepresentation( kCFAllocatorDefault, c_path.as_ptr(), c_len as CFIndex, false, ); let mut placeholder = CFURLCopyAbsoluteURL(url); CFRelease(url); let imaginary: CFRef = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); while !CFURLResourceIsReachable(placeholder, ptr::null_mut()) { let child = CFURLCopyLastPathComponent(placeholder); CFArrayInsertValueAtIndex(imaginary, 0, child); CFRelease(child); url = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, placeholder); CFRelease(placeholder); placeholder = url; } url = CFURLCreateFileReferenceURL(kCFAllocatorDefault, placeholder, err); if !err.is_null() { return ptr::null_mut(); } CFRelease(placeholder); placeholder = CFURLCreateFilePathURL(kCFAllocatorDefault, url, err); if !err.is_null() { return ptr::null_mut(); } CFRelease(url); if imaginary != kCFAllocatorDefault { let mut count = 0; while count < CFArrayGetCount(imaginary) { let component = CFArrayGetValueAtIndex(imaginary, count); url = CFURLCreateCopyAppendingPathComponent( kCFAllocatorDefault, placeholder, component, false, ); CFRelease(placeholder); placeholder = url; count += 1; } CFRelease(imaginary); } let cf_path = CFURLCopyFileSystemPath(placeholder, kCFURLPOSIXPathStyle); CFRelease(placeholder); cf_path } fsevent-sys-3.0.0/src/fsevent.rs010064400007650000024000000117231353651740200150400ustar0000000000000000#![allow(non_upper_case_globals, non_camel_case_types)] use core_foundation as cf; pub type FSEventStreamRef = *mut ::std::os::raw::c_void; pub type FSEventStreamCallback = extern "C" fn( FSEventStreamRef, // ConstFSEventStreamRef streamRef *mut ::std::os::raw::c_void, // void *clientCallBackInfo usize, // size_t numEvents *mut ::std::os::raw::c_void, // void *eventPaths *const ::std::os::raw::c_void, // const FSEventStreamEventFlags eventFlags[] *const ::std::os::raw::c_void, // const FSEventStreamEventId eventIds[] ); pub type FSEventStreamEventId = u64; pub const kFSEventStreamEventIdSinceNow: FSEventStreamEventId = 0xFFFFFFFFFFFFFFFF; pub type FSEventStreamCreateFlags = std::os::raw::c_uint; pub const kFSEventStreamCreateFlagNone: FSEventStreamCreateFlags = 0x00000000; pub const kFSEventStreamCreateFlagUseCFTypes: FSEventStreamCreateFlags = 0x00000001; pub const kFSEventStreamCreateFlagNoDefer: FSEventStreamCreateFlags = 0x00000002; pub const kFSEventStreamCreateFlagWatchRoot: FSEventStreamCreateFlags = 0x00000004; pub const kFSEventStreamCreateFlagIgnoreSelf: FSEventStreamCreateFlags = 0x00000008; pub const kFSEventStreamCreateFlagFileEvents: FSEventStreamCreateFlags = 0x00000010; pub const kFSEventStreamCreateFlagMarkSelf: FSEventStreamCreateFlags = 0x00000020; pub const kFSEventStreamCreateFlagUseExtendedData: FSEventStreamCreateFlags = 0x00000040; pub type FSEventStreamEventFlags = std::os::raw::c_uint; pub const kFSEventStreamEventFlagNone: FSEventStreamEventFlags = 0x00000000; pub const kFSEventStreamEventFlagMustScanSubDirs: FSEventStreamEventFlags = 0x00000001; pub const kFSEventStreamEventFlagUserDropped: FSEventStreamEventFlags = 0x00000002; pub const kFSEventStreamEventFlagKernelDropped: FSEventStreamEventFlags = 0x00000004; pub const kFSEventStreamEventFlagEventIdsWrapped: FSEventStreamEventFlags = 0x00000008; pub const kFSEventStreamEventFlagHistoryDone: FSEventStreamEventFlags = 0x00000010; pub const kFSEventStreamEventFlagRootChanged: FSEventStreamEventFlags = 0x00000020; pub const kFSEventStreamEventFlagMount: FSEventStreamEventFlags = 0x00000040; pub const kFSEventStreamEventFlagUnmount: FSEventStreamEventFlags = 0x00000080; pub const kFSEventStreamEventFlagItemCreated: FSEventStreamEventFlags = 0x00000100; pub const kFSEventStreamEventFlagItemRemoved: FSEventStreamEventFlags = 0x00000200; pub const kFSEventStreamEventFlagItemInodeMetaMod: FSEventStreamEventFlags = 0x00000400; pub const kFSEventStreamEventFlagItemRenamed: FSEventStreamEventFlags = 0x00000800; pub const kFSEventStreamEventFlagItemModified: FSEventStreamEventFlags = 0x00001000; pub const kFSEventStreamEventFlagItemFinderInfoMod: FSEventStreamEventFlags = 0x00002000; pub const kFSEventStreamEventFlagItemChangeOwner: FSEventStreamEventFlags = 0x00004000; pub const kFSEventStreamEventFlagItemXattrMod: FSEventStreamEventFlags = 0x00008000; pub const kFSEventStreamEventFlagItemIsFile: FSEventStreamEventFlags = 0x00010000; pub const kFSEventStreamEventFlagItemIsDir: FSEventStreamEventFlags = 0x00020000; pub const kFSEventStreamEventFlagItemIsSymlink: FSEventStreamEventFlags = 0x00040000; pub const kFSEventStreamEventFlagOwnEvent: FSEventStreamEventFlags = 0x00080000; pub const kFSEventStreamEventFlagItemIsHardlink: FSEventStreamEventFlags = 0x00100000; pub const kFSEventStreamEventFlagItemIsLastHardlink: FSEventStreamEventFlags = 0x00200000; pub const kFSEventStreamEventFlagItemCloned: FSEventStreamEventFlags = 0x00400000; #[repr(C)] pub struct FSEventStreamContext { pub version: cf::CFIndex, pub info: *mut ::std::os::raw::c_void, pub retain: Option, pub release: Option, pub copy_description: Option, } // impl Clone for FSEventStreamContext { } // impl Copy for FSEventStreamContext { } #[link(name = "CoreServices", kind = "framework")] extern "C" { pub fn FSEventStreamCreate( allocator: cf::CFAllocatorRef, callback: FSEventStreamCallback, context: *const FSEventStreamContext, pathsToWatch: cf::CFMutableArrayRef, sinceWhen: FSEventStreamEventId, latency: cf::CFTimeInterval, flags: FSEventStreamCreateFlags, ) -> FSEventStreamRef; pub fn FSEventStreamShow(stream_ref: FSEventStreamRef); pub fn FSEventStreamScheduleWithRunLoop( stream_ref: FSEventStreamRef, run_loop: cf::CFRunLoopRef, run_loop_mode: cf::CFStringRef, ); pub fn FSEventStreamUnscheduleFromRunLoop( stream_ref: FSEventStreamRef, run_loop: cf::CFRunLoopRef, run_loop_mode: cf::CFStringRef, ); pub fn FSEventStreamStart(stream_ref: FSEventStreamRef) -> cf::Boolean; pub fn FSEventStreamFlushSync(stream_ref: FSEventStreamRef); pub fn FSEventStreamStop(stream_ref: FSEventStreamRef); pub fn FSEventStreamInvalidate(stream_ref: FSEventStreamRef); pub fn FSEventStreamRelease(stream_ref: FSEventStreamRef); } fsevent-sys-3.0.0/src/lib.rs010064400007650000024000000001761327054146600141360ustar0000000000000000#![cfg_attr(feature = "cargo-clippy", allow(unreadable_literal))] pub mod core_foundation; mod fsevent; pub use fsevent::*; fsevent-sys-3.0.0/.cargo_vcs_info.json0000644000000001120000000000000133530ustar00{ "git": { "sha1": "7c1b935f6f206026d9af298d2b35f8ea4dd150d6" } }