mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 11:01:54 +00:00
17c203fef9
This isn't exactly a great solution, but it's a step in the right direction, and it's simple allowing us to quickly unblock linux. Without this (or an equivalent) PR linux builds are broken. I spent a bunch of time investigating using notify on macos, and have a branch with that working and FakeFs updated to use notify events. unfortunately I think this would come with some drawbacks. Primarily that files that don't yet exist yet aren't handled as well as with using events directly leading to some less than ideal tradeoffs. This PR is very much a placeholder for a better cross platform solution. Most problematically, it only fills in the portion of fsevent::Event that is currently used, despite there being a lot more information in the ones collected from macos. At the very least a followup PR should hide those implementation details behind a cross platform Event type so that if people try and access data that hasn't been translated, they find out about it. Release Notes: - N/A
122 lines
4 KiB
Rust
122 lines
4 KiB
Rust
#[cfg(target_os = "macos")]
|
|
pub use mac_impl::*;
|
|
|
|
use bitflags::bitflags;
|
|
use std::path::PathBuf;
|
|
|
|
#[cfg(target_os = "macos")]
|
|
mod mac_impl;
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct Event {
|
|
pub event_id: u64,
|
|
pub flags: StreamFlags,
|
|
pub path: PathBuf,
|
|
}
|
|
|
|
// Synchronize with
|
|
// /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/FSEvents.framework/Versions/A/Headers/FSEvents.h
|
|
bitflags! {
|
|
#[repr(C)]
|
|
pub struct StreamFlags: u32 {
|
|
const NONE = 0x00000000;
|
|
const MUST_SCAN_SUBDIRS = 0x00000001;
|
|
const USER_DROPPED = 0x00000002;
|
|
const KERNEL_DROPPED = 0x00000004;
|
|
const IDS_WRAPPED = 0x00000008;
|
|
const HISTORY_DONE = 0x00000010;
|
|
const ROOT_CHANGED = 0x00000020;
|
|
const MOUNT = 0x00000040;
|
|
const UNMOUNT = 0x00000080;
|
|
const ITEM_CREATED = 0x00000100;
|
|
const ITEM_REMOVED = 0x00000200;
|
|
const INODE_META_MOD = 0x00000400;
|
|
const ITEM_RENAMED = 0x00000800;
|
|
const ITEM_MODIFIED = 0x00001000;
|
|
const FINDER_INFO_MOD = 0x00002000;
|
|
const ITEM_CHANGE_OWNER = 0x00004000;
|
|
const ITEM_XATTR_MOD = 0x00008000;
|
|
const IS_FILE = 0x00010000;
|
|
const IS_DIR = 0x00020000;
|
|
const IS_SYMLINK = 0x00040000;
|
|
const OWN_EVENT = 0x00080000;
|
|
const IS_HARDLINK = 0x00100000;
|
|
const IS_LAST_HARDLINK = 0x00200000;
|
|
const ITEM_CLONED = 0x400000;
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for StreamFlags {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
if self.contains(StreamFlags::MUST_SCAN_SUBDIRS) {
|
|
let _d = write!(f, "MUST_SCAN_SUBDIRS ");
|
|
}
|
|
if self.contains(StreamFlags::USER_DROPPED) {
|
|
let _d = write!(f, "USER_DROPPED ");
|
|
}
|
|
if self.contains(StreamFlags::KERNEL_DROPPED) {
|
|
let _d = write!(f, "KERNEL_DROPPED ");
|
|
}
|
|
if self.contains(StreamFlags::IDS_WRAPPED) {
|
|
let _d = write!(f, "IDS_WRAPPED ");
|
|
}
|
|
if self.contains(StreamFlags::HISTORY_DONE) {
|
|
let _d = write!(f, "HISTORY_DONE ");
|
|
}
|
|
if self.contains(StreamFlags::ROOT_CHANGED) {
|
|
let _d = write!(f, "ROOT_CHANGED ");
|
|
}
|
|
if self.contains(StreamFlags::MOUNT) {
|
|
let _d = write!(f, "MOUNT ");
|
|
}
|
|
if self.contains(StreamFlags::UNMOUNT) {
|
|
let _d = write!(f, "UNMOUNT ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_CREATED) {
|
|
let _d = write!(f, "ITEM_CREATED ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_REMOVED) {
|
|
let _d = write!(f, "ITEM_REMOVED ");
|
|
}
|
|
if self.contains(StreamFlags::INODE_META_MOD) {
|
|
let _d = write!(f, "INODE_META_MOD ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_RENAMED) {
|
|
let _d = write!(f, "ITEM_RENAMED ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_MODIFIED) {
|
|
let _d = write!(f, "ITEM_MODIFIED ");
|
|
}
|
|
if self.contains(StreamFlags::FINDER_INFO_MOD) {
|
|
let _d = write!(f, "FINDER_INFO_MOD ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_CHANGE_OWNER) {
|
|
let _d = write!(f, "ITEM_CHANGE_OWNER ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_XATTR_MOD) {
|
|
let _d = write!(f, "ITEM_XATTR_MOD ");
|
|
}
|
|
if self.contains(StreamFlags::IS_FILE) {
|
|
let _d = write!(f, "IS_FILE ");
|
|
}
|
|
if self.contains(StreamFlags::IS_DIR) {
|
|
let _d = write!(f, "IS_DIR ");
|
|
}
|
|
if self.contains(StreamFlags::IS_SYMLINK) {
|
|
let _d = write!(f, "IS_SYMLINK ");
|
|
}
|
|
if self.contains(StreamFlags::OWN_EVENT) {
|
|
let _d = write!(f, "OWN_EVENT ");
|
|
}
|
|
if self.contains(StreamFlags::IS_LAST_HARDLINK) {
|
|
let _d = write!(f, "IS_LAST_HARDLINK ");
|
|
}
|
|
if self.contains(StreamFlags::IS_HARDLINK) {
|
|
let _d = write!(f, "IS_HARDLINK ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_CLONED) {
|
|
let _d = write!(f, "ITEM_CLONED ");
|
|
}
|
|
write!(f, "")
|
|
}
|
|
}
|