Page 1 of 1

About Question enthuware.ocpjp.v8.2.1175 :

Posted: Tue May 16, 2017 9:10 pm
by lenalena
I'm a bit confused about the symbolic link part of the explanation..
This method copies a file to the target file with the options parameter specifying how the copy is performed. By default, the copy fails if the target file already exists or is a symbolic link, except if the source and target are the same file, in which case the method completes without copying the file. File attributes are not required to be copied to the target file. If symbolic links are supported, and the file is a symbolic link, then the final target of the link is copied. If the file is a directory then it creates an empty directory in the target location (entries in the directory are not copied).
Based on this, if the target is a symbolic link, the copy will fail. What does "If symbolic links are supported, and the file is a symbolic link" mean exactly? Is it talking about the source file here? And is the support of symbolic links default and platform specific or is defined through an option?

The way I understand this explanation, if symbolic links are supported and source and destination are BOTH symbolic links - then copy will fail because the target is a symbolic link. If only the source is the symbolic link, then copy will succeed an the target will be copied.

If NOFOLLOW_LINKS option is set and the source is a symbolic link then the link will be copied and not the target file.

A symbolic link in the target file will always cause the method to fail (regardless of support of symbolic links and NOFOLLOW_LINKS option)

Also, what happens if the source file is a symbolic link and symbolic links are not supported. Exception?

Re: About Question enthuware.ocpjp.v8.2.1175 :

Posted: Tue May 16, 2017 9:32 pm
by admin
lenalena wrote:I'm a bit confused about the symbolic link part of the explanation..
This method copies a file to the target file with the options parameter specifying how the copy is performed. By default, the copy fails if the target file already exists or is a symbolic link, except if the source and target are the same file, in which case the method completes without copying the file. File attributes are not required to be copied to the target file. If symbolic links are supported, and the file is a symbolic link, then the final target of the link is copied. If the file is a directory then it creates an empty directory in the target location (entries in the directory are not copied).
Based on this, if the target is a symbolic link, the copy will fail. What does "If symbolic links are supported, and the file is a symbolic link" mean exactly?
Symbolic links are a feature of the file system. Operations on them depend on that particular file system. So "supported" means implemented by the file system.
Is it talking about the source file here? And is the support of symbolic links default and platform specific or is defined through an option?
Source as well as destination. It talks about both. As mentioned above, it depends on the file system.
The way I understand this explanation, if symbolic links are supported and source and destination are BOTH symbolic links - then copy will fail because the target is a symbolic link. If only the source is the symbolic link, then copy will succeed an the target will be copied.

If NOFOLLOW_LINKS option is set and the source is a symbolic link then the link will be copied and not the target file.

A symbolic link in the target file will always cause the method to fail (regardless of support of symbolic links and NOFOLLOW_LINKS option)
Correct.
Also, what happens if the source file is a symbolic link and symbolic links are not supported. Exception?
Yes, the signature of copy method has IOException in its list of possible exceptions. So you will get that or its subclass in case symbolic links are not supported.

HTH,
Paul.

Re: About Question enthuware.ocpjp.v8.2.1175 :

Posted: Tue May 16, 2017 9:59 pm
by lenalena
Alright, thank you for clarifying.

Re: About Question enthuware.ocpjp.v8.2.1175 :

Posted: Sun Aug 26, 2018 4:02 am
by thodoris.bais
The respective Javadoc defines ATOMIC_MOVE, instead of NO_FOLLOW_LINKS.
Thus, I think this should also be changed here.

Re: About Question enthuware.ocpjp.v8.2.1175 :

Posted: Sat Sep 01, 2018 10:58 am
by thodoris.bais
@admin ? any news here?
Is what I fore-mentioned right?

Re: About Question enthuware.ocpjp.v8.2.1175 :

Posted: Sun Sep 02, 2018 2:08 am
by admin
I am not sure I understand your point. The JavaDoc specifies three values - REPLACE_EXISTING, COPY_ATTRIBUTES, and NOFOLLOW_LINKS.

-Paul.