RFR: 8293122: (fs) Use file cloning in macOS version of Files::copy method

Brian Burkhalter bpb at openjdk.org
Wed Sep 7 17:02:45 UTC 2022


On Wed, 7 Sep 2022 15:14:18 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Use BSD system call `clonefile` if possible when using `Files::copy` on macOS.
>
> src/java.base/macosx/classes/sun/nio/fs/BsdFileSystem.java line 141:
> 
>> 139:         // cancellation is not possible, or attributes are not to be copied
>> 140:         if (!cloneFileNotSupported && addressToPollForCancel == 0 &&
>> 141:             flags.copyPosixAttributes) {
> 
> This will need some thought as this means it will only be used when Files.copy is invoked with the COPY_ATTRIBUTES option.

`clonefile` appears to copy all attributes so if it is acceptable for that to occur if `COPY_ATTRIBUTES` is not set, then the `flags.copyPosixAttributes` check could be removed.

-------------

PR: https://git.openjdk.org/jdk/pull/10188


More information about the nio-dev mailing list