Java Code Examples for com.sun.nio.file.ExtendedWatchEventModifier#FILE_TREE

The following examples show how to use com.sun.nio.file.ExtendedWatchEventModifier#FILE_TREE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WindowsPath.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 2
Source File: WindowsPath.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 3
Source File: WindowsPath.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 4
Source File: WindowsPath.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 5
Source File: WindowsPath.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 6
Source File: DirectoryWatcher.java    From directory-watcher with Apache License 2.0 5 votes vote down vote up
private void register(Path directory, boolean useFileTreeModifier) throws IOException {
  logger.debug("Registering [{}].", directory);
  Watchable watchable = isMac ? new WatchablePath(directory) : directory;
  WatchEvent.Modifier[] modifiers =
      useFileTreeModifier
          ? new WatchEvent.Modifier[] {ExtendedWatchEventModifier.FILE_TREE}
          : new WatchEvent.Modifier[] {};
  WatchEvent.Kind<?>[] kinds =
      new WatchEvent.Kind<?>[] {ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY};
  WatchKey watchKey = watchable.register(watchService, kinds, modifiers);
  keyRoots.put(watchKey, directory);
}
 
Example 7
Source File: WindowsPath.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 8
Source File: WindowsPath.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 9
Source File: WindowsPath.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 10
Source File: WindowsPath.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 11
Source File: WindowsPath.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 12
Source File: WindowsPath.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 13
Source File: WindowsPath.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}