package rarpcken;
import java.io.File;
import java.io.FileFilter;
import net.contentobjects.jnotify.JNotify;
import net.contentobjects.jnotify.JNotifyListener;
public class Main
{
public static void main(String[] args)
{
}
// to add a watch :
String pathname = System.getProperty("user.home");
// watch mask
int mask = JNotify.FILE_CREATED | JNotify.FILE_DELETED | JNotify.FILE_MODIFIED | JNotify.FILE_RENAMED;
//watch subtree?
boolean watchSubtree = true;
// add actual watch
int watchID = JNotify.addWatch(pathname, mask, watchSubtree, new JNotifyListener() { //hier erscheint ein ewig langer Fehler
public boolean accept( File pathname ) {
return pathname.isFile();
}
}; //hier kommt expected ')'
public final static FileFilter DIRECTORY = new FileFilter() {
@Override
public boolean accept( File pathname ) {
return pathname.isDirectory();
}
};
public final static FileFilter IMAGE = new FileFilter() {
String[] ext = { ".jpg", ".bmp", ".png", ".gif" };
@Override
public boolean accept( File pathname ) {
return hasExtension(pathname, ext);
}
};
public final static FileFilter VIDEO = new FileFilter() {
String[] ext = { ".avi", ".wmv", ".mpeg", ".divx" };
@Override
public boolean accept( File pathname ) {
return hasExtension(pathname, ext);
}
};
public final static FileFilter AUDIO = new FileFilter() {
String[] ext = { ".mp3", ".wma", ".ogg" };
@Override
public boolean accept( File pathname ) {
return hasExtension(pathname, ext);
}
};
public final static FileFilter MP3 = new FileFilter() {
@Override
public boolean accept( File pathname ) {
return hasExtension(pathname, new String[] { ".mp3" });
}
};
private static boolean hasExtension( File pathname, String[] types ) {
String name = pathname.getName();
for ( String type : types ) {
if ( name.endsWith(type) )
return true;
System.out.println(name); /* damit ich seh ob es überhaupt klaptt
und die richtigen daten dann auch an rar
übergeben werden kann*/
}
return false;
}
}
// sleep a little, the application will exit if you
// don't (watching is asynchrnous), depending on your
// application, this may not be required
try //class interface,or rnum expected
{
Thread.sleep(6000);
} //class interface,or rnum expected
catch (InterruptedException e1)
{
}
// to remove watch the watch
boolean res = JNotify.removeWatch(watchID);
if (!res) //class interface,or rnum expected
{
// invalid watch ID specified.
}