@@ -77,18 +77,6 @@ private static IoPolicy getIoPolicy() {
7777 }
7878 }
7979
80- protected final FileSystem fileSystem ;
81-
82- /**
83- * Opens a {@link FileSystemKeyValueAccess} with a {@link FileSystem}.
84- *
85- * @param fileSystem the file system
86- */
87- public FileSystemKeyValueAccess (final FileSystem fileSystem ) {
88-
89- this .fileSystem = fileSystem ;
90- }
91-
9280 @ Override
9381 public VolatileReadData createReadData (final String normalPath ) throws N5IOException {
9482
@@ -116,14 +104,14 @@ public void write(final String normalPath, final ReadData data) throws N5IOExcep
116104 @ Deprecated
117105 public LockedFileChannel lockForReading (final String normalPath ) throws N5IOException {
118106
119- return lockForReading (fileSystem . getPath (normalPath ));
107+ return lockForReading (Paths . get (normalPath ));
120108 }
121109
122110 @ Override
123111 @ Deprecated
124112 public LockedChannel lockForWriting (final String normalPath ) throws N5IOException {
125113
126- return lockForWriting (fileSystem . getPath (normalPath ));
114+ return lockForWriting (Paths . get (normalPath ));
127115 }
128116
129117 @ Deprecated
@@ -153,28 +141,28 @@ static LockedFileChannel lockForWriting(final Path path) throws N5IOException {
153141 @ Override
154142 public boolean isDirectory (final String normalPath ) {
155143
156- final Path path = fileSystem . getPath (normalPath );
144+ final Path path = Paths . get (normalPath );
157145 return Files .isDirectory (path );
158146 }
159147
160148 @ Override
161149 public boolean isFile (final String normalPath ) {
162150
163- final Path path = fileSystem . getPath (normalPath );
151+ final Path path = Paths . get (normalPath );
164152 return Files .isRegularFile (path );
165153 }
166154
167155 @ Override
168156 public boolean exists (final String normalPath ) {
169157
170- final Path path = fileSystem . getPath (normalPath );
158+ final Path path = Paths . get (normalPath );
171159 return Files .exists (path );
172160 }
173161
174162 @ Override
175163 public long size (final String normalPath ) {
176164
177- return size (fileSystem . getPath (normalPath ));
165+ return size (Paths . get (normalPath ));
178166 }
179167
180168 protected static long size (final Path path ) {
@@ -191,7 +179,7 @@ protected static long size(final Path path) {
191179 @ Override
192180 public String [] listDirectories (final String normalPath ) throws N5IOException {
193181
194- final Path path = fileSystem . getPath (normalPath );
182+ final Path path = Paths . get (normalPath );
195183 try (final Stream <Path > pathStream = Files .list (path )) {
196184 return pathStream
197185 .filter (Files ::isDirectory )
@@ -207,7 +195,7 @@ public String[] listDirectories(final String normalPath) throws N5IOException {
207195 @ Override
208196 public String [] list (final String normalPath ) throws N5IOException {
209197
210- final Path path = fileSystem . getPath (normalPath );
198+ final Path path = Paths . get (normalPath );
211199 try (final Stream <Path > pathStream = Files .list (path )) {
212200 return pathStream
213201 .map (a -> path .relativize (a ).toString ())
@@ -222,8 +210,9 @@ public String[] list(final String normalPath) throws N5IOException {
222210 @ Override
223211 public String [] components (final String path ) {
224212
225- final Path fsPath = fileSystem . getPath (path );
213+ final Path fsPath = Paths . get (path );
226214 final Path root = fsPath .getRoot ();
215+ String separator = root .getFileSystem ().getSeparator ();
227216 final String [] components ;
228217 int o ;
229218 if (root == null ) {
@@ -239,7 +228,6 @@ public String[] components(final String path) {
239228 String name = fsPath .getName (i - o ).toString ();
240229 /* Preserve trailing slash on final component if present*/
241230 if (i == components .length - 1 ) {
242- final String separator = fileSystem .getSeparator ();
243231 final String trailingSeparator = path .endsWith (separator ) ? separator : path .endsWith ("/" ) ? "/" : "" ;
244232 name += trailingSeparator ;
245233 }
@@ -251,7 +239,7 @@ public String[] components(final String path) {
251239 @ Override
252240 public String parent (final String path ) {
253241
254- final Path parent = fileSystem . getPath (path ).getParent ();
242+ final Path parent = Paths . get (path ).getParent ();
255243 if (parent == null )
256244 return null ;
257245 else
@@ -261,8 +249,8 @@ public String parent(final String path) {
261249 @ Override
262250 public String relativize (final String path , final String base ) {
263251
264- final Path basePath = fileSystem . getPath (base );
265- return basePath .relativize (fileSystem . getPath (path )).toString ();
252+ final Path basePath = Paths . get (base );
253+ return basePath .relativize (Paths . get (path )).toString ();
266254 }
267255
268256 /**
@@ -277,7 +265,7 @@ public String relativize(final String path, final String base) {
277265 @ Override
278266 public String normalize (final String path ) {
279267
280- return fileSystem . getPath (path ).normalize ().toString ();
268+ return Paths . get (path ).normalize ().toString ();
281269 }
282270
283271 @ Override
@@ -300,8 +288,8 @@ public String compose(final String... components) {
300288 if (components == null || components .length == 0 )
301289 return null ;
302290 if (components .length == 1 )
303- return fileSystem . getPath (components [0 ]).toString ();
304- return fileSystem . getPath (components [0 ], Arrays .copyOfRange (components , 1 , components .length )).normalize ().toString ();
291+ return Paths . get (components [0 ]).toString ();
292+ return Paths . get (components [0 ], Arrays .copyOfRange (components , 1 , components .length )).normalize ().toString ();
305293 }
306294
307295 @ Override public String compose (URI uri , String ... components ) {
@@ -324,7 +312,7 @@ public String compose(final String... components) {
324312 public void createDirectories (final String normalPath ) throws N5IOException {
325313
326314 try {
327- createDirectories (fileSystem . getPath (normalPath ));
315+ createDirectories (Paths . get (normalPath ));
328316 } catch (NoSuchFileException e ) {
329317 throw new N5NoSuchKeyException ("No such file" , e );
330318 } catch (IOException | UncheckedIOException e ) {
@@ -336,13 +324,13 @@ public void createDirectories(final String normalPath) throws N5IOException {
336324 public void delete (final String normalPath ) throws N5IOException {
337325
338326 try {
339- final Path path = fileSystem . getPath (normalPath );
327+ final Path path = Paths . get (normalPath );
340328
341329 if (Files .isRegularFile (path ))
342330 ioPolicy .delete (normalPath );
343331 else {
344332 try (final Stream <Path > pathStream = Files .walk (path )) {
345- for (final Iterator <Path > i = pathStream .sorted (Comparator .reverseOrder ()).iterator (); i .hasNext ();) {
333+ for (final Iterator <Path > i = pathStream .sorted (Comparator .reverseOrder ()).iterator (); i .hasNext (); ) {
346334 final Path childPath = i .next ();
347335 if (Files .isRegularFile (childPath ))
348336 ioPolicy .delete (childPath .toString ());
0 commit comments