author | henryjen |
Thu, 09 May 2013 14:44:56 -0700 | |
changeset 17696 | 23a863fbb6c3 |
parent 9050 | 26c2c1de1631 |
permissions | -rw-r--r-- |
4679
5feae448a41f
6917021: (file) copyTo/moveTo can overrwrite existing file when target associated with custom provider
alanb
parents:
diff
changeset
|
1 |
/* |
17696 | 2 |
* Copyright (c) 2010, 2013, 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 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
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 | 57 |
static Path unwrap(Path wrapper) { |
58 |
if (wrapper == null) |
|
59 |
throw new NullPointerException(); |
|
60 |
if (!(wrapper instanceof PassThroughPath)) |
|
61 |
throw new ProviderMismatchException(); |
|
62 |
return ((PassThroughPath)wrapper).delegate; |
|
63 |
} |
|
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 | 128 |
public Path getPath(String first, String... more) { |
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 | 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 | 210 |
|
211 |
@Override |
|
212 |
public void setAttribute(Path file, String attribute, Object value, LinkOption... options) |
|
213 |
throws IOException |
|
214 |
{ |
|
215 |
Files.setAttribute(unwrap(file), attribute, value, options); |
|
216 |
} |
|
217 |
||
218 |
@Override |
|
219 |
public Map<String,Object> readAttributes(Path file, String attributes, LinkOption... options) |
|
220 |
throws IOException |
|
221 |
{ |
|
222 |
return Files.readAttributes(unwrap(file), attributes, options); |
|
223 |
} |
|
224 |
||
225 |
@Override |
|
226 |
public <V extends FileAttributeView> V getFileAttributeView(Path file, |
|
227 |
Class<V> type, |
|
228 |
LinkOption... options) |
|
229 |
{ |
|
230 |
return Files.getFileAttributeView(unwrap(file), type, options); |
|
231 |
} |
|
232 |
||
233 |
@Override |
|
234 |
public <A extends BasicFileAttributes> A readAttributes(Path file, |
|
235 |
Class<A> type, |
|
236 |
LinkOption... options) |
|
237 |
throws IOException |
|
238 |
{ |
|
239 |
return Files.readAttributes(unwrap(file), type, options); |
|
240 |
} |
|
241 |
||
242 |
@Override |
|
243 |
public void delete(Path file) throws IOException { |
|
244 |
Files.delete(unwrap(file)); |
|
245 |
} |
|
246 |
||
247 |
@Override |
|
248 |
public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) |
|
249 |
throws IOException |
|
250 |
{ |
|
251 |
Files.createSymbolicLink(unwrap(link), unwrap(target), attrs); |
|
252 |
} |
|
253 |
||
254 |
@Override |
|
255 |
public void createLink(Path link, Path existing) throws IOException { |
|
256 |
Files.createLink(unwrap(link), unwrap(existing)); |
|
257 |
} |
|
258 |
||
259 |
@Override |
|
260 |
public Path readSymbolicLink(Path link) throws IOException { |
|
261 |
Path target = Files.readSymbolicLink(unwrap(link)); |
|
262 |
return new PassThroughPath(delegate, target); |
|
263 |
} |
|
264 |
||
265 |
||
266 |
@Override |
|
267 |
public void copy(Path source, Path target, CopyOption... options) throws IOException { |
|
268 |
Files.copy(unwrap(source), unwrap(target), options); |
|
269 |
} |
|
270 |
||
271 |
@Override |
|
272 |
public void move(Path source, Path target, CopyOption... options) throws IOException { |
|
273 |
Files.move(unwrap(source), unwrap(target), options); |
|
274 |
} |
|
275 |
||
276 |
private DirectoryStream<Path> wrap(final DirectoryStream<Path> stream) { |
|
277 |
return new DirectoryStream<Path>() { |
|
278 |
@Override |
|
279 |
public Iterator<Path> iterator() { |
|
280 |
final Iterator<Path> itr = stream.iterator(); |
|
281 |
return new Iterator<Path>() { |
|
282 |
@Override |
|
283 |
public boolean hasNext() { |
|
284 |
return itr.hasNext(); |
|
285 |
} |
|
286 |
@Override |
|
287 |
public Path next() { |
|
288 |
return new PassThroughPath(delegate, itr.next()); |
|
289 |
} |
|
290 |
@Override |
|
291 |
public void remove() { |
|
292 |
itr.remove(); |
|
293 |
} |
|
294 |
}; |
|
295 |
} |
|
296 |
@Override |
|
297 |
public void close() throws IOException { |
|
298 |
stream.close(); |
|
299 |
} |
|
300 |
}; |
|
301 |
} |
|
302 |
||
303 |
@Override |
|
304 |
public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) |
|
305 |
throws IOException |
|
306 |
{ |
|
17696 | 307 |
return wrap(Files.newDirectoryStream(unwrap(dir), filter)); |
8158 | 308 |
} |
309 |
||
310 |
@Override |
|
311 |
public void createDirectory(Path dir, FileAttribute<?>... attrs) |
|
312 |
throws IOException |
|
313 |
{ |
|
314 |
Files.createDirectory(unwrap(dir), attrs); |
|
315 |
} |
|
316 |
||
317 |
@Override |
|
318 |
public SeekableByteChannel newByteChannel(Path file, |
|
319 |
Set<? extends OpenOption> options, |
|
320 |
FileAttribute<?>... attrs) |
|
321 |
throws IOException |
|
322 |
{ |
|
323 |
return Files.newByteChannel(unwrap(file), options, attrs); |
|
324 |
} |
|
325 |
||
326 |
||
327 |
@Override |
|
328 |
public boolean isHidden(Path file) throws IOException { |
|
329 |
return Files.isHidden(unwrap(file)); |
|
330 |
} |
|
331 |
||
332 |
@Override |
|
333 |
public FileStore getFileStore(Path file) throws IOException { |
|
334 |
return Files.getFileStore(unwrap(file)); |
|
335 |
} |
|
336 |
||
337 |
@Override |
|
338 |
public boolean isSameFile(Path file, Path other) throws IOException { |
|
339 |
return Files.isSameFile(unwrap(file), unwrap(other)); |
|
340 |
} |
|
341 |
||
342 |
@Override |
|
343 |
public void checkAccess(Path file, AccessMode... modes) |
|
344 |
throws IOException |
|
345 |
{ |
|
346 |
// hack |
|
347 |
if (modes.length == 0) { |
|
348 |
if (Files.exists(unwrap(file))) |
|
349 |
return; |
|
350 |
else |
|
351 |
throw new NoSuchFileException(file.toString()); |
|
352 |
} |
|
353 |
throw new RuntimeException("not implemented yet"); |
|
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 | 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 | 396 |
public Path getFileName() { |
397 |
return wrap(delegate.getFileName()); |
|
398 |
} |
|
399 |
||
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 | 416 |
public boolean startsWith(String other) { |
417 |
return delegate.startsWith(other); |
|
418 |
} |
|
419 |
||
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 | 426 |
public boolean endsWith(String other) { |
427 |
return delegate.endsWith(other); |
|
428 |
} |
|
429 |
||
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 | 446 |
public Path resolveSibling(Path other) { |
447 |
return wrap(delegate.resolveSibling(unwrap(other))); |
|
448 |
} |
|
449 |
||
450 |
@Override |
|
451 |
public Path resolveSibling(String other) { |
|
452 |
return wrap(delegate.resolveSibling(other)); |
|
453 |
} |
|
454 |
||
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 | 461 |
public boolean equals(Object other) { |
462 |
if (!(other instanceof PassThroughPath)) |
|
463 |
return false; |
|
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 | 468 |
public int hashCode() { |
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 | 473 |
public String toString() { |
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 |
9025
a72fc1fc4b71
7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents:
8158
diff
changeset
|
489 |
public Path toRealPath(LinkOption... options) throws IOException { |
a72fc1fc4b71
7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents:
8158
diff
changeset
|
490 |
return wrap(delegate.toRealPath(options)); |
4679
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 | 494 |
public File toFile() { |
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 | 523 |
public WatchKey register(WatchService watcher, |
524 |
WatchEvent.Kind<?>[] events, |
|
525 |
WatchEvent.Modifier... modifiers) |
|
526 |
{ |
|
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 | 531 |
public WatchKey register(WatchService watcher, |
532 |
WatchEvent.Kind<?>... events) |
|
533 |
{ |
|
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 |
} |