GithubHelp home page GithubHelp logo

futureopener / libfsmonitor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eswick/libfsmonitor

0.0 2.0 0.0 263 KB

Library for monitoring iOS / OS X filesystems.

License: MIT License

Objective-C 63.99% Makefile 2.48% C 30.46% Shell 3.07%

libfsmonitor's Introduction

libfsmonitor

##Overview##

libfsmonitor is an Objective-C library allows processes to be notified upon various filesystem events, such as files being created, modified, or deleted. The daemon (fsmonitord) trails /dev/fsevents and parses the data into an NSDictionary, which is then sent via CPDistributedNotificationCenter to any interested clients. Included is a small wrapper around CPDistributedNotificationCenter which handles listening and directory filtering.

Usage

Classes wishing to receive filesystem notification events must conform to the FSMonitorDelegate protocol.

Initialization

FSMonitor *filesystemMonitor = [FSMonitor new];
filesystemMonitor.delegate = self;

[filesystemMonitor addDirectoryFilter:[NSURL URLWithString:@"/path/to/monitor/"]];

Delegate Method

- (void)monitor:(FSMonitor*)monitor recievedEventInfo:(NSDictionary*)info{
    FSMonitorEventType type = [[info objectForKey:@"TYPE"] intValue];
    switch(type){
        case FSMonitorEventTypeRename:
        {
            NSString *originalName = [[info objectForKey:@"FILE"] path];
            NSString *newName = [[info objectForKey:@"DEST_FILE"] path];
            break;
        }
        case FSMonitorEventTypeDeletion:
            ...

Event Info

The info dictionary contains information about the event. All events include the following keys and their corresponding values:

  • FILE
  • The path of the file or directory involved with the event.
  • DEVICE_MAJOR
  • The major value of the physical drive FILE is located on.
  • DEVICE_MINOR
  • The minor value of the physical drive FILE is located on.
  • INODE
  • Whatever the hell an inode is.
  • MODE
  • The read/write/execute protections on FILE.
  • UID
  • The UID of the process that caused the event.
  • GID
  • The GID of the process that caused the event.

The only exception is FSMonitorEventTypeRename, which contains one extra value:

  • DEST_FILE
  • The path of the new file.

libfsmonitor's People

Contributors

eswick avatar

Watchers

James Cloos avatar  avatar

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.