当前位置: 首页>>代码示例>>Java>>正文


Java ExtendedWatchEventModifier类代码示例

本文整理汇总了Java中com.sun.nio.file.ExtendedWatchEventModifier的典型用法代码示例。如果您正苦于以下问题:Java ExtendedWatchEventModifier类的具体用法?Java ExtendedWatchEventModifier怎么用?Java ExtendedWatchEventModifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ExtendedWatchEventModifier类属于com.sun.nio.file包,在下文中一共展示了ExtendedWatchEventModifier类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: FileWatcher

import com.sun.nio.file.ExtendedWatchEventModifier; //导入依赖的package包/类
public FileWatcher(final Path watchedDirectory) throws IOException {
	this.watchedDirectory = toCanonicalPath(watchedDirectory);
	watcher = FileSystems.getDefault().newWatchService();
	watchedDirectory.register(watcher, new Kind[] {StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY}, ExtendedWatchEventModifier.FILE_TREE);
	thread.setDaemon(true);
	thread.start();
}
 
开发者ID:Njol,项目名称:Motunautr,代码行数:8,代码来源:FileWatcher.java

示例2: register

import com.sun.nio.file.ExtendedWatchEventModifier; //导入依赖的package包/类
@Override
public WatchKey register(WatchService watcher,
                         WatchEvent.Kind<?>[] events,
                         WatchEvent.Modifier... modifiers)
    throws IOException
{
    if (watcher == null)
        throw new NullPointerException();
    if (!(watcher instanceof WindowsWatchService))
        throw new ProviderMismatchException();

    // When a security manager is set then we need to make a defensive
    // copy of the modifiers and check for the Windows specific FILE_TREE
    // modifier. When the modifier is present then check that permission
    // has been granted recursively.
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        boolean watchSubtree = false;
        final int ml = modifiers.length;
        if (ml > 0) {
            modifiers = Arrays.copyOf(modifiers, ml);
            int i=0;
            while (i < ml) {
                if (modifiers[i++] == ExtendedWatchEventModifier.FILE_TREE) {
                    watchSubtree = true;
                    break;
                }
            }
        }
        String s = getPathForPermissionCheck();
        sm.checkRead(s);
        if (watchSubtree)
            sm.checkRead(s + "\\-");
    }

    return ((WindowsWatchService)watcher).register(this, events, modifiers);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:WindowsPath.java

示例3: register

import com.sun.nio.file.ExtendedWatchEventModifier; //导入依赖的package包/类
/**
     * Register the given directory with the WatchService
     */
    private void register(Path dir) throws IOException {
//        WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
    	// following works better on Mac OS X, which as of Java7 does not use native watchservice.  OS X still slow relative to PC.  See:
    	WatchKey key;
    	// http://stackoverflow.com/questions/9588737/is-java-7-watchservice-slow-for-anyone-else
    	try {		// Windows (only) supports built-in recursive monitoring
    		key = dir.register(watcher, new WatchEvent.Kind[]{ENTRY_MODIFY, ENTRY_CREATE, ENTRY_DELETE}, SensitivityWatchEventModifier.HIGH, ExtendedWatchEventModifier.FILE_TREE);
    	} catch(Exception e) {
    		key = dir.register(watcher, new WatchEvent.Kind[]{ENTRY_MODIFY, ENTRY_CREATE, ENTRY_DELETE}, SensitivityWatchEventModifier.HIGH);
    	}
    	
        keys.put(key, dir);
    }
 
开发者ID:cycronix,项目名称:cloudturbine,代码行数:17,代码来源:CTsync.java

示例4: register

import com.sun.nio.file.ExtendedWatchEventModifier; //导入依赖的package包/类
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException
{
    if (!(watcher instanceof NetFileSystem.NetWatchService))
    {
        // null check
        watcher.getClass();
        throw new ProviderMismatchException();
    }
    boolean create = false;
    boolean delete = false;
    boolean modify = false;
    boolean overflow = false;
    boolean subtree = false;
    for (WatchEvent.Kind<?> kind : events)
    {
        if (kind == StandardWatchEventKinds.ENTRY_CREATE)
        {
            create = true;
        }
        else if (kind == StandardWatchEventKinds.ENTRY_DELETE)
        {
            delete = true;
        }
        else if (kind == StandardWatchEventKinds.ENTRY_MODIFY)
        {
            modify = true;
        }
        else if (kind == StandardWatchEventKinds.OVERFLOW)
        {
            overflow = true;
        }
        else
        {
            // null check
            kind.getClass();
            throw new UnsupportedOperationException();
        }
    }
    if (!create && !delete && !modify)
    {
        throw new IllegalArgumentException();
    }
    for (WatchEvent.Modifier modifier : modifiers)
    {
        if (modifier == ExtendedWatchEventModifier.FILE_TREE)
        {
            subtree = true;
        }
        else if (modifier instanceof SensitivityWatchEventModifier)
        {
            // ignore
        }
        else
        {
            // null check
            modifier.getClass();
            throw new UnsupportedOperationException();
        }
    }
    SecurityManager sm = System.getSecurityManager();
    if (sm != null)
    {
        sm.checkRead(path);
        if (subtree)
        {
            sm.checkRead(path + cli.System.IO.Path.DirectorySeparatorChar + '-');
        }
    }
    return ((NetFileSystem.NetWatchService)watcher).register(this, create, delete, modify, overflow, subtree);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:71,代码来源:NetPath.java


注:本文中的com.sun.nio.file.ExtendedWatchEventModifier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。