Witness

使用 Swift 监控文件系统更改。Witness 为 OS X 的 File System Events API 提供了一个封装。

安装

推荐在你的项目中使用 Carthage 来引入 Witness。只需将这行代码添加到你的 Cartfile

github "njdehoog/Witness" ~> 0.1

用法

导入框架

import Witness

监控文件系统事件

当桌面目录中的文件被创建、删除或修改时,这将触发一个事件。

if let desktopPath = NSSearchPathForDirectoriesInDomains(.desktopDirectory, .userDomainMask, true).first {
    self.witness = Witness(paths: [desktopPath], flags: .FileEvents, latency: 0.3) { events in
        print("file system events received: \(events)")
    }
}

贡献

  1. Fork 本项目!
  2. 创建你的特性分支: git checkout -b my-new-feature
  3. 提交你的更改: git commit -am 'Add some feature'
  4. 推送到分支: git push origin my-new-feature
  5. 提交 pull request :D

鸣谢

Witness 的开发是为了在 Spelt 中使用。如果你喜欢这个库,请考虑购买该应用以支持开发。

许可

Witness 基于 MIT 许可发布。详情请参阅 LICENSE 文件。