Add 'noFollowSymbolicLink' argument to 'exists'

This commit is contained in:
JeremyStar™ 2024-12-16 02:36:55 +01:00
parent f7855afc3e
commit f0c43d7b53
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -335,13 +335,17 @@ class FileAccess {
/**
* Returns if this file or directory exists.
*
* @param noFollowSymbolicLink checks the symbolic link destination if `false`, checks the link itself if `true`. Has no effect if there doesn't exist a link at this location
* @return exists?
* @throws IOAccessException on IO error
* @since v1-alpha10
*/
@Throws(IOAccessException::class)
fun exists(): Boolean {
return Files.exists(path)
fun exists(noFollowSymbolicLink: Boolean = false): Boolean {
return if (noFollowSymbolicLink)
Files.exists(path, LinkOption.NOFOLLOW_LINKS)
else
Files.exists(path)
}
/**