mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8322166: Files.isReadable/isWritable/isExecutable expensive when file does not exist
Reviewed-by: alanb
This commit is contained in:
parent
0f8e4e0a81
commit
51be857f3c
6 changed files with 98 additions and 50 deletions
|
@ -893,7 +893,9 @@ abstract class UnixFileSystem
|
|||
sourceAttrs = UnixFileAttributes.get(source, false);
|
||||
if (sourceAttrs.isDirectory()) {
|
||||
// ensure source can be moved
|
||||
access(source, W_OK);
|
||||
int errno = access(source, W_OK);
|
||||
if (errno != 0)
|
||||
new UnixException(errno).rethrowAsIOException(source);
|
||||
}
|
||||
} catch (UnixException x) {
|
||||
x.rethrowAsIOException(source);
|
||||
|
@ -1024,13 +1026,11 @@ abstract class UnixFileSystem
|
|||
|
||||
// ensure source can be copied
|
||||
if (!sourceAttrs.isSymbolicLink() || flags.followLinks) {
|
||||
try {
|
||||
// the access(2) system call always follows links so it
|
||||
// is suppressed if the source is an unfollowed link
|
||||
access(source, R_OK);
|
||||
} catch (UnixException exc) {
|
||||
exc.rethrowAsIOException(source);
|
||||
}
|
||||
// the access(2) system call always follows links so it
|
||||
// is suppressed if the source is an unfollowed link
|
||||
int errno = access(source, R_OK);
|
||||
if (errno != 0)
|
||||
new UnixException(errno).rethrowAsIOException(source);
|
||||
}
|
||||
|
||||
// get attributes of target file (don't follow links)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue