本文整理汇总了Java中com.sun.nio.file.ExtendedWatchEventModifier.FILE_TREE属性的典型用法代码示例。如果您正苦于以下问题:Java ExtendedWatchEventModifier.FILE_TREE属性的具体用法?Java ExtendedWatchEventModifier.FILE_TREE怎么用?Java ExtendedWatchEventModifier.FILE_TREE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sun.nio.file.ExtendedWatchEventModifier
的用法示例。
在下文中一共展示了ExtendedWatchEventModifier.FILE_TREE属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: register
@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);
}
示例2: register
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);
}