jdk/test/java/nio/file/Files/PassThroughFileSystem.java
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 8158 77d9c0f1c19f
child 9050 26c2c1de1631
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8158
diff changeset
     2
 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
     4
 *
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
     8
 *
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    13
 * accompanied this code).
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    14
 *
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4679
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4679
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4679
diff changeset
    21
 * questions.
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    22
 */
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    23
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    24
import java.nio.file.*;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    25
import java.nio.file.attribute.*;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    26
import java.nio.file.spi.FileSystemProvider;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    27
import java.nio.channels.SeekableByteChannel;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    28
import java.net.URI;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    29
import java.util.*;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    30
import java.io.*;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    31
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    32
/**
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    33
 * A "pass through" file system implementation that passes through, or delegates,
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    34
 * everything to the default file system.
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    35
 */
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    36
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    37
class PassThroughFileSystem extends FileSystem {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    38
    private final FileSystemProvider provider;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    39
    private final FileSystem delegate;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    40
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    41
    PassThroughFileSystem(FileSystemProvider provider, FileSystem delegate) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    42
        this.provider = provider;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    43
        this.delegate = delegate;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    44
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    45
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    46
    /**
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    47
     * Creates a new "pass through" file system. Useful for test environments
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    48
     * where the provider might not be deployed.
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    49
     */
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    50
    static FileSystem create() throws IOException {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    51
        FileSystemProvider provider = new PassThroughProvider();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    52
        Map<String,?> env = Collections.emptyMap();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    53
        URI uri = URI.create("pass:///");
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    54
        return provider.newFileSystem(uri, env);
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    55
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    56
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
    57
    static Path unwrap(Path wrapper) {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
    58
        if (wrapper == null)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
    59
            throw new NullPointerException();
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
    60
        if (!(wrapper instanceof PassThroughPath))
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
    61
            throw new ProviderMismatchException();
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
    62
        return ((PassThroughPath)wrapper).delegate;
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
    63
    }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
    64
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    65
    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    66
    public FileSystemProvider provider() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    67
        return provider;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    68
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    69
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    70
    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    71
    public void close() throws IOException {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    72
        delegate.close();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    73
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    74
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    75
    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    76
    public boolean isOpen() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    77
        return delegate.isOpen();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    78
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    79
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    80
    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    81
    public boolean isReadOnly() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    82
        return delegate.isReadOnly();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    83
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    84
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    85
    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    86
    public String getSeparator() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    87
        return delegate.getSeparator();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    88
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    89
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    90
    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    91
    public Iterable<Path> getRootDirectories() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    92
        final Iterable<Path> roots = delegate.getRootDirectories();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    93
        return new Iterable<Path>() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    94
            @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    95
            public Iterator<Path> iterator() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    96
                final Iterator<Path> itr = roots.iterator();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    97
                return new Iterator<Path>() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    98
                    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
    99
                    public boolean hasNext() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   100
                        return itr.hasNext();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   101
                    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   102
                    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   103
                    public Path next() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   104
                        return new PassThroughPath(delegate, itr.next());
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   105
                    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   106
                    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   107
                    public void remove() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   108
                        itr.remove();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   109
                    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   110
                };
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   111
            }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   112
        };
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   113
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   114
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   115
    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   116
    public Iterable<FileStore> getFileStores() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   117
        // assume that unwrapped objects aren't exposed
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   118
        return delegate.getFileStores();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   119
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   120
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   121
    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   122
    public Set<String> supportedFileAttributeViews() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   123
        // assume that unwrapped objects aren't exposed
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   124
        return delegate.supportedFileAttributeViews();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   125
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   126
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   127
    @Override
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   128
    public Path getPath(String first, String... more) {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   129
        return new PassThroughPath(this, delegate.getPath(first, more));
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   130
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   131
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   132
    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   133
    public PathMatcher getPathMatcher(String syntaxAndPattern) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   134
        final PathMatcher matcher = delegate.getPathMatcher(syntaxAndPattern);
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   135
        return new PathMatcher() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   136
            @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   137
            public boolean matches(Path path) {
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   138
                return matcher.matches(unwrap(path));
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   139
            }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   140
        };
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   141
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   142
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   143
    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   144
    public UserPrincipalLookupService getUserPrincipalLookupService() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   145
        // assume that unwrapped objects aren't exposed
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   146
        return delegate.getUserPrincipalLookupService();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   147
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   148
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   149
    @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   150
    public WatchService newWatchService() throws IOException {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   151
        // to keep it simple
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   152
        throw new UnsupportedOperationException();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   153
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   154
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   155
    static class PassThroughProvider extends FileSystemProvider {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   156
        private static final String SCHEME = "pass";
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   157
        private static volatile PassThroughFileSystem delegate;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   158
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   159
        public PassThroughProvider() { }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   160
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   161
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   162
        public String getScheme() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   163
            return SCHEME;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   164
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   165
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   166
        private void checkScheme(URI uri) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   167
            if (!uri.getScheme().equalsIgnoreCase(SCHEME))
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   168
                throw new IllegalArgumentException();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   169
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   170
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   171
        private void checkUri(URI uri) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   172
            checkScheme(uri);
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   173
            if (!uri.getSchemeSpecificPart().equals("///"))
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   174
                throw new IllegalArgumentException();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   175
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   176
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   177
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   178
        public FileSystem newFileSystem(URI uri, Map<String,?> env)
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   179
            throws IOException
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   180
        {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   181
            checkUri(uri);
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   182
            synchronized (PassThroughProvider.class) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   183
                if (delegate != null)
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   184
                    throw new FileSystemAlreadyExistsException();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   185
                PassThroughFileSystem result =
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   186
                    new PassThroughFileSystem(this, FileSystems.getDefault());
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   187
                delegate = result;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   188
                return result;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   189
            }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   190
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   191
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   192
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   193
        public FileSystem getFileSystem(URI uri) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   194
            checkUri(uri);
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   195
            FileSystem result = delegate;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   196
            if (result == null)
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   197
                throw new FileSystemNotFoundException();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   198
            return result;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   199
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   200
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   201
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   202
        public Path getPath(URI uri) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   203
            checkScheme(uri);
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   204
            if (delegate == null)
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   205
                throw new FileSystemNotFoundException();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   206
            uri = URI.create(delegate.provider().getScheme() + ":" +
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   207
                             uri.getSchemeSpecificPart());
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   208
            return new PassThroughPath(delegate, delegate.provider().getPath(uri));
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   209
        }
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   210
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   211
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   212
        public void setAttribute(Path file, String attribute, Object value, LinkOption... options)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   213
            throws IOException
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   214
        {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   215
            Files.setAttribute(unwrap(file), attribute, value, options);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   216
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   217
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   218
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   219
        public Map<String,Object> readAttributes(Path file, String attributes, LinkOption... options)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   220
            throws IOException
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   221
        {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   222
            return Files.readAttributes(unwrap(file), attributes, options);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   223
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   224
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   225
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   226
        public <V extends FileAttributeView> V getFileAttributeView(Path file,
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   227
                                                                    Class<V> type,
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   228
                                                                    LinkOption... options)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   229
        {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   230
            return Files.getFileAttributeView(unwrap(file), type, options);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   231
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   232
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   233
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   234
        public <A extends BasicFileAttributes> A readAttributes(Path file,
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   235
                                                                Class<A> type,
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   236
                                                                LinkOption... options)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   237
            throws IOException
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   238
        {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   239
            return Files.readAttributes(unwrap(file), type, options);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   240
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   241
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   242
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   243
        public void delete(Path file) throws IOException {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   244
            Files.delete(unwrap(file));
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   245
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   246
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   247
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   248
        public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   249
            throws IOException
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   250
        {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   251
            Files.createSymbolicLink(unwrap(link), unwrap(target), attrs);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   252
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   253
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   254
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   255
        public void createLink(Path link, Path existing) throws IOException {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   256
            Files.createLink(unwrap(link), unwrap(existing));
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   257
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   258
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   259
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   260
        public Path readSymbolicLink(Path link) throws IOException {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   261
            Path target = Files.readSymbolicLink(unwrap(link));
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   262
            return new PassThroughPath(delegate, target);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   263
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   264
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   265
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   266
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   267
        public void copy(Path source, Path target, CopyOption... options) throws IOException {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   268
            Files.copy(unwrap(source), unwrap(target), options);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   269
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   270
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   271
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   272
        public void move(Path source, Path target, CopyOption... options) throws IOException {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   273
            Files.move(unwrap(source), unwrap(target), options);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   274
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   275
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   276
        private DirectoryStream<Path> wrap(final DirectoryStream<Path> stream) {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   277
            return new DirectoryStream<Path>() {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   278
                @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   279
                public Iterator<Path> iterator() {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   280
                    final Iterator<Path> itr = stream.iterator();
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   281
                    return new Iterator<Path>() {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   282
                        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   283
                        public boolean hasNext() {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   284
                            return itr.hasNext();
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   285
                        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   286
                        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   287
                        public Path next() {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   288
                            return new PassThroughPath(delegate, itr.next());
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   289
                        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   290
                        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   291
                        public void remove() {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   292
                            itr.remove();
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   293
                        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   294
                    };
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   295
                }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   296
                @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   297
                public void close() throws IOException {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   298
                    stream.close();
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   299
                }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   300
            };
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   301
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   302
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   303
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   304
        public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   305
            throws IOException
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   306
        {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   307
            return wrap(Files.newDirectoryStream(dir, filter));
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   308
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   309
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   310
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   311
        public void createDirectory(Path dir, FileAttribute<?>... attrs)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   312
            throws IOException
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   313
        {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   314
            Files.createDirectory(unwrap(dir), attrs);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   315
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   316
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   317
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   318
        public SeekableByteChannel newByteChannel(Path file,
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   319
                                                  Set<? extends OpenOption> options,
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   320
                                                  FileAttribute<?>... attrs)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   321
            throws IOException
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   322
        {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   323
            return Files.newByteChannel(unwrap(file), options, attrs);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   324
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   325
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   326
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   327
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   328
        public boolean isHidden(Path file) throws IOException {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   329
            return Files.isHidden(unwrap(file));
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   330
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   331
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   332
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   333
        public FileStore getFileStore(Path file) throws IOException {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   334
            return Files.getFileStore(unwrap(file));
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   335
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   336
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   337
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   338
        public boolean isSameFile(Path file, Path other) throws IOException {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   339
            return Files.isSameFile(unwrap(file), unwrap(other));
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   340
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   341
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   342
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   343
        public void checkAccess(Path file, AccessMode... modes)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   344
            throws IOException
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   345
        {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   346
            // hack
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   347
            if (modes.length == 0) {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   348
                if (Files.exists(unwrap(file)))
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   349
                    return;
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   350
                else
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   351
                    throw new NoSuchFileException(file.toString());
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   352
            }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   353
            throw new RuntimeException("not implemented yet");
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   354
        }
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   355
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   356
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   357
    static class PassThroughPath implements Path {
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   358
        private final FileSystem fs;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   359
        private final Path delegate;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   360
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   361
        PassThroughPath(FileSystem fs, Path delegate) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   362
            this.fs = fs;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   363
            this.delegate = delegate;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   364
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   365
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   366
        private Path wrap(Path path) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   367
            return (path != null) ? new PassThroughPath(fs, path) : null;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   368
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   369
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   370
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   371
        public FileSystem getFileSystem() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   372
            return fs;
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   373
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   374
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   375
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   376
        public boolean isAbsolute() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   377
            return delegate.isAbsolute();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   378
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   379
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   380
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   381
        public Path getRoot() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   382
            return wrap(delegate.getRoot());
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   383
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   384
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   385
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   386
        public Path getParent() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   387
            return wrap(delegate.getParent());
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   388
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   389
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   390
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   391
        public int getNameCount() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   392
            return delegate.getNameCount();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   393
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   394
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   395
        @Override
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   396
        public Path getFileName() {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   397
            return wrap(delegate.getFileName());
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   398
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   399
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   400
        @Override
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   401
        public Path getName(int index) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   402
            return wrap(delegate.getName(index));
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   403
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   404
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   405
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   406
        public Path subpath(int beginIndex, int endIndex) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   407
            return wrap(delegate.subpath(beginIndex, endIndex));
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   408
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   409
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   410
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   411
        public boolean startsWith(Path other) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   412
            return delegate.startsWith(unwrap(other));
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   413
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   414
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   415
        @Override
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   416
        public boolean startsWith(String other) {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   417
            return delegate.startsWith(other);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   418
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   419
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   420
        @Override
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   421
        public boolean endsWith(Path other) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   422
            return delegate.endsWith(unwrap(other));
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   423
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   424
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   425
        @Override
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   426
        public boolean endsWith(String other) {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   427
            return delegate.endsWith(other);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   428
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   429
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   430
        @Override
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   431
        public Path normalize() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   432
            return wrap(delegate.normalize());
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   433
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   434
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   435
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   436
        public Path resolve(Path other) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   437
            return wrap(delegate.resolve(unwrap(other)));
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   438
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   439
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   440
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   441
        public Path resolve(String other) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   442
            return wrap(delegate.resolve(other));
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   443
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   444
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   445
        @Override
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   446
        public Path resolveSibling(Path other) {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   447
            return wrap(delegate.resolveSibling(unwrap(other)));
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   448
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   449
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   450
        @Override
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   451
        public Path resolveSibling(String other) {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   452
            return wrap(delegate.resolveSibling(other));
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   453
        }
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   454
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   455
        @Override
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   456
        public Path relativize(Path other) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   457
            return wrap(delegate.relativize(unwrap(other)));
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   458
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   459
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   460
        @Override
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   461
        public boolean equals(Object other) {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   462
            if (!(other instanceof PassThroughPath))
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   463
                return false;
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   464
            return delegate.equals(unwrap((PassThroughPath)other));
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   465
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   466
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   467
        @Override
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   468
        public int hashCode() {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   469
            return delegate.hashCode();
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   470
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   471
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   472
        @Override
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   473
        public String toString() {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   474
            return delegate.toString();
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   475
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   476
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   477
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   478
        public URI toUri() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   479
            String ssp = delegate.toUri().getSchemeSpecificPart();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   480
            return URI.create(fs.provider().getScheme() + ":" + ssp);
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   481
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   482
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   483
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   484
        public Path toAbsolutePath() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   485
            return wrap(delegate.toAbsolutePath());
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   486
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   487
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   488
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   489
        public Path toRealPath(boolean resolveLinks) throws IOException {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   490
            return wrap(delegate.toRealPath(resolveLinks));
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   491
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   492
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   493
        @Override
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   494
        public File toFile() {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   495
            return delegate.toFile();
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   496
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   497
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   498
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   499
        public Iterator<Path> iterator() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   500
            final Iterator<Path> itr = delegate.iterator();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   501
            return new Iterator<Path>() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   502
                @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   503
                public boolean hasNext() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   504
                    return itr.hasNext();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   505
                }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   506
                @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   507
                public Path next() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   508
                    return wrap(itr.next());
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   509
                }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   510
                @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   511
                public void remove() {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   512
                    itr.remove();
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   513
                }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   514
            };
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   515
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   516
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   517
        @Override
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   518
        public int compareTo(Path other) {
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   519
            return delegate.compareTo(unwrap(other));
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   520
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   521
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   522
        @Override
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   523
        public WatchKey register(WatchService watcher,
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   524
                                      WatchEvent.Kind<?>[] events,
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   525
                                      WatchEvent.Modifier... modifiers)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   526
        {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   527
            throw new UnsupportedOperationException();
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   528
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   529
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   530
        @Override
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   531
        public  WatchKey register(WatchService watcher,
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   532
                                      WatchEvent.Kind<?>... events)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   533
        {
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 5506
diff changeset
   534
            throw new UnsupportedOperationException();
4679
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   535
        }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   536
    }
5feae448a41f 6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff changeset
   537
}