mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8371689: (fs) CopyMoveHelper.copyToForeignTarget use of sourcePosixView is confusing
Reviewed-by: alanb
This commit is contained in:
parent
52ffe8a096
commit
9ec773ad27
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -109,21 +109,21 @@ class CopyMoveHelper {
|
||||
LinkOption[] linkOptions = (opts.followLinks) ? new LinkOption[0] :
|
||||
new LinkOption[] { LinkOption.NOFOLLOW_LINKS };
|
||||
|
||||
// retrieve source posix view, null if unsupported
|
||||
final PosixFileAttributeView sourcePosixView =
|
||||
Files.getFileAttributeView(source, PosixFileAttributeView.class);
|
||||
// determine whether the source supports posix attributes
|
||||
boolean sourceSupportsPosixAttributes = Files.getFileAttributeView
|
||||
(source, PosixFileAttributeView.class) != null;
|
||||
|
||||
// attributes of source file
|
||||
BasicFileAttributes sourceAttrs = null;
|
||||
if (sourcePosixView != null) {
|
||||
if (sourceSupportsPosixAttributes)
|
||||
sourceAttrs = Files.readAttributes(source,
|
||||
PosixFileAttributes.class,
|
||||
linkOptions);
|
||||
}
|
||||
if (sourceAttrs == null)
|
||||
else
|
||||
sourceAttrs = Files.readAttributes(source,
|
||||
BasicFileAttributes.class,
|
||||
linkOptions);
|
||||
|
||||
assert sourceAttrs != null;
|
||||
|
||||
if (sourceAttrs.isSymbolicLink())
|
||||
@ -151,7 +151,7 @@ class CopyMoveHelper {
|
||||
// copy basic and, if supported, POSIX attributes to target
|
||||
if (opts.copyAttributes) {
|
||||
BasicFileAttributeView targetView = null;
|
||||
if (sourcePosixView != null) {
|
||||
if (sourceSupportsPosixAttributes) {
|
||||
targetView = Files.getFileAttributeView(target,
|
||||
PosixFileAttributeView.class);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user