Code Monkey home page Code Monkey logo

witness's Introduction

Witness

Monitor file system changes using Swift. Witness provides a wrapper around the File System Events API for OS X.

Installation

The recommended way to include Witness in your project is by using Carthage. Simply add this line to your Cartfile:

github "njdehoog/Witness" ~> 0.1

Usage

Import the framework

import Witness

Monitor file system events

This will trigger an event when a file in the Desktop directory is created, deleted or modified.

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)")
    }
}

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Credits

Witness was developed for use in Spelt. If you like this library, please consider supporting development by purchasing the app.

License

Witness is released under the MIT license. See LICENSE for details.

witness's People

Contributors

njdehoog avatar perlmunger avatar spencerkohan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

witness's Issues

Support Swift 4

Hi @njdehoog,

I will be submitting a PR for this issue. Please review when at your earliest convenience.

Need a new version tag

I like that you added support for Swift Package Manager, but it needs to have a new tag (say 0.1.4). I can test things in my application by specifying the master branch, but I can't do that in my production version since the package management in Xcode will not allow the mix. Specifically I get the following:

because package libs-ebedcore is required using a version-based requirement and it depends on unversion package witness and no versions of libs-EbedCore match the requirement 2.3.1..<3.0.0, libs-EbedCore >=2.3.0 is forbidden.
And because root depends on libs-EbedCore 2.3.0..<3.0.0, version solving failed.

While I can work around that while I'm testing since I also use a branch for my libs-ebedcore library, when I switch to using a specific version, it fails complaining that the specific version (libs-ebedcore v2.3.0) is depending on a non-versioned (Witness) prerequisite.

Would you be willing to take your current commit "b046945" as version 0.1.4? That would help me out a lot.

Seemingly duplicated events for a change

I added a watch to a folder (Source) with a file (first.txt), and when I change the contents of that file, I get this exact event 150 times:

▿ FileEvent
  - path : "/Users/revolt/Downloads/Source/first.txt"
  ▿ flags : Item created,Item Renamed,Item Modified,Item Change Owner,Item Is File
    - rawValue : 4282624

Maybe I'm receiving the "Item created" event for a simple content modification because of Vim, but shouldn't I receive only one "Item Modified" event?

I tried using echo "new content" > first.txt and I get a lot of times this event:

▿ FileEvent
  - path : "/Users/revolt/Downloads/Source/first.txt"
  ▿ flags : Item Inode Meta Modification,Item Modified,Item Is File
    - rawValue : 4264960

Improve repository description and add tags

Thanks for the project! While this is one of the most up to date and neatest projects it seems a little tricky to find. Consider changing description to include file system events watch swift and adding tags. More will find it. More will use it. More will contribute.

2018-06-11 12 02 48

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.