8336675: Remove UnixFileSystemProvider.checkPath in favor of UnixPath.toUnixPath
Reviewed-by: jpai, alanb, bpb
This commit is contained in:
parent
902bada2cd
commit
f5871df25c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -45,7 +45,6 @@ import java.nio.file.NotDirectoryException;
|
|||||||
import java.nio.file.NotLinkException;
|
import java.nio.file.NotLinkException;
|
||||||
import java.nio.file.OpenOption;
|
import java.nio.file.OpenOption;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.ProviderMismatchException;
|
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
import java.nio.file.attribute.BasicFileAttributeView;
|
import java.nio.file.attribute.BasicFileAttributeView;
|
||||||
import java.nio.file.attribute.FileAttribute;
|
import java.nio.file.attribute.FileAttribute;
|
||||||
@ -126,14 +125,6 @@ public abstract class UnixFileSystemProvider
|
|||||||
return UnixUriUtils.fromUri(theFileSystem, uri);
|
return UnixUriUtils.fromUri(theFileSystem, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnixPath checkPath(Path obj) {
|
|
||||||
if (obj == null)
|
|
||||||
throw new NullPointerException();
|
|
||||||
if (!(obj instanceof UnixPath))
|
|
||||||
throw new ProviderMismatchException();
|
|
||||||
return (UnixPath)obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <V extends FileAttributeView> V getFileAttributeView(Path obj,
|
public <V extends FileAttributeView> V getFileAttributeView(Path obj,
|
||||||
@ -216,7 +207,7 @@ public abstract class UnixFileSystemProvider
|
|||||||
FileAttribute<?>... attrs)
|
FileAttribute<?>... attrs)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
UnixPath file = checkPath(obj);
|
UnixPath file = UnixPath.toUnixPath(obj);
|
||||||
int mode = UnixFileModeAttribute
|
int mode = UnixFileModeAttribute
|
||||||
.toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
|
.toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
|
||||||
try {
|
try {
|
||||||
@ -233,7 +224,7 @@ public abstract class UnixFileSystemProvider
|
|||||||
ExecutorService executor,
|
ExecutorService executor,
|
||||||
FileAttribute<?>... attrs) throws IOException
|
FileAttribute<?>... attrs) throws IOException
|
||||||
{
|
{
|
||||||
UnixPath file = checkPath(obj);
|
UnixPath file = UnixPath.toUnixPath(obj);
|
||||||
int mode = UnixFileModeAttribute
|
int mode = UnixFileModeAttribute
|
||||||
.toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
|
.toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
|
||||||
ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
|
ThreadPool pool = (executor == null) ? null : ThreadPool.wrap(executor, 0);
|
||||||
@ -253,15 +244,7 @@ public abstract class UnixFileSystemProvider
|
|||||||
FileAttribute<?>... attrs)
|
FileAttribute<?>... attrs)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
UnixPath file = UnixPath.toUnixPath(obj);
|
return newFileChannel(obj, options, attrs);
|
||||||
int mode = UnixFileModeAttribute
|
|
||||||
.toUnixMode(UnixFileModeAttribute.ALL_READWRITE, attrs);
|
|
||||||
try {
|
|
||||||
return UnixChannelFactory.newFileChannel(file, options, mode);
|
|
||||||
} catch (UnixException x) {
|
|
||||||
x.rethrowAsIOException(file);
|
|
||||||
return null; // keep compiler happy
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user