sun.nio.fs.BasicFileAttributesHolder Java Examples

The following examples show how to use sun.nio.fs.BasicFileAttributesHolder. 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: FileTreeWalker.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #2
Source File: FileTreeWalker.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #3
Source File: FileTreeWalker.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #4
Source File: FileTreeWalker.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #5
Source File: FileTreeWalker.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #6
Source File: FileTreeWalker.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #7
Source File: FileTreeWalker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #8
Source File: FileTreeWalker.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #9
Source File: FileTreeWalker.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #10
Source File: FileTreeWalker.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #11
Source File: FileTreeWalker.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #12
Source File: FileTreeWalker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #13
Source File: FileTreeWalker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #14
Source File: FileTreeWalker.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #15
Source File: FileTreeWalker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #16
Source File: FileTreeWalker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}
 
Example #17
Source File: FileTreeWalker.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the attributes of the given file, taking into account whether
 * the walk is following sym links is not. The {@code canUseCached}
 * argument determines whether this method can use cached attributes.
 */
private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
    throws IOException
{
    // if attributes are cached then use them if possible
    if (canUseCached &&
        (file instanceof BasicFileAttributesHolder) &&
        (System.getSecurityManager() == null))
    {
        BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
        if (cached != null && (!followLinks || !cached.isSymbolicLink())) {
            return cached;
        }
    }

    // attempt to get attributes of file. If fails and we are following
    // links then a link target might not exist so get attributes of link
    BasicFileAttributes attrs;
    try {
        attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
    } catch (IOException ioe) {
        if (!followLinks)
            throw ioe;

        // attempt to get attrmptes without following links
        attrs = Files.readAttributes(file,
                                     BasicFileAttributes.class,
                                     LinkOption.NOFOLLOW_LINKS);
    }
    return attrs;
}