Coder Social home page Coder Social logo

shimanshe / jnotify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mdonoughe/jnotify

0.0 1.0 0.0 492 KB

Obsolete fork of JNotify. Use 0.93 or higher instead.

Home Page: http://jnotify.sourceforge.net/

Makefile 10.25% C++ 17.17% C 13.55% Java 59.02%

jnotify's Introduction

JNotify works on Linux with INotify support (Tested on 2.6.14), Mac OS X 10.5 or higher (Tested on 10.5.8), and Windows XP/2K/NT (Tested on XP).

Because of the way Mac OS X handles file change notifications, some things may work differently. Other platforms still work the same way as before, but if you want your code to work everywhere, you should be aware of the following:

  • Events are not guaranteed to be reported in order. Events should be reported within two seconds of occuring.
  • File changes that are present less than two seconds may be missed. For example, mv a b && mv b c may report only a single rename.
  • The code that detects renames is only aware of files being watched. If a file outside the watched directory is moved into the directory, it will be reported as a create. Likewise, if a file is moved out of the watched directory, it will be reported as a delete.

To use JNotify, You will need to have the appropriate shared library in your java.library.path

Usage is very simple:

// to add a watch : 
String path = "/home/omry/tmp";
int mask = JNotify.FILE_CREATED | 
           JNotify.FILE_DELETED | 
           JNotify.FILE_MODIFIED| 
           JNotify.FILE_RENAMED;
boolean watchSubtree = true;
int watchID = JNotify.addWatch(path, mask, watchSubtree, new JNotifyListener()
{
  public void fileRenamed(int wd, String rootPath, String oldName,
      String newName)
  {
    System.out.println("JNotifyTest.fileRenamed() : wd #" + wd + " root = "
        + rootPath + ", " + oldName + " -> " + newName);
  }

  public void fileModified(int wd, String rootPath, String name)
  {
    System.out.println("JNotifyTest.fileModified() : wd #" + wd + " root = "
        + rootPath + ", " + name);
  }

  public void fileDeleted(int wd, String rootPath, String name)
  {
    System.out.println("JNotifyTest.fileDeleted() : wd #" + wd + " root = "
        + rootPath + ", " + name);
  }

  public void fileCreated(int wd, String rootPath, String name)
  {
    System.out.println("JNotifyTest.fileCreated() : wd #" + wd + " root = "
        + rootPath + ", " + name);
  }
});

// to remove watch:
boolean res = JNotify.removeWatch(watchID);
if (!res)
{
  // invalid watch ID specified.
}

jnotify's People

Contributors

omry avatar mdonoughe avatar

Watchers

James Cloos 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.