Remove never working hard link detection

This commit is contained in:
JeremyStar™ 2024-12-16 02:34:53 +01:00
parent 0f49fff498
commit 6389aaa5d0
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -490,10 +490,10 @@ class FileAccess {
}
/**
* Returns the destination of
* this symbolic or hard link.
* Returns the destination
* of this symbolic link.
*
* @return destination or `null` if not a symbolic or hard link
* @return destination or `null` if not a symbolic link
* @throws IOAccessException on IO error
* @since v1-alpha10
*/
@ -504,6 +504,7 @@ class FileAccess {
} catch (exception: Exception) {
when (exception) {
is NotLinkException, is UnsupportedOperationException -> null
is IOException -> throw IOAccessException("Failed to get the link destination for '${unformatFromPath(path)}'", exception)
else -> throw exception
}
}
@ -1098,8 +1099,8 @@ class FileAccess {
* @since v1-alpha10
*/
@Throws(IOAccessException::class, VerificationFailedException::class)
fun verifyExists(): FileAccess {
if (!exists())
fun verifyExists(noFollowSymbolicLink: Boolean = false): FileAccess {
if (!exists(noFollowSymbolicLink = noFollowSymbolicLink))
throw VerificationFailedException("Expected that something exists at '${unformatFromPath(path)}'")
return this
@ -1115,8 +1116,8 @@ class FileAccess {
* @since v1-alpha10
*/
@Throws(IOAccessException::class, VerificationFailedException::class)
fun verifyNotExists(): FileAccess {
if (exists())
fun verifyNotExists(noFollowSymbolicLink: Boolean = false): FileAccess {
if (exists(noFollowSymbolicLink = noFollowSymbolicLink))
throw VerificationFailedException("Expected that nothing exists at '${unformatFromPath(path)}'")
return this
@ -1201,7 +1202,7 @@ class FileAccess {
*/
@Throws(IOAccessException::class, VerificationFailedException::class)
fun verifyIsLink(): FileAccess {
if (exists() && (isSymbolicLink() || getLinkDestination() != null))
if (exists() && isSymbolicLink())
throw VerificationFailedException("Expected that '${unformatFromPath(path)}' is a link")
return this
@ -1218,6 +1219,40 @@ class FileAccess {
*/
@Throws(IOAccessException::class, VerificationFailedException::class)
fun verifyIsNotLink(): FileAccess {
if (exists() && !isSymbolicLink())
throw VerificationFailedException("Expected that '${unformatFromPath(path)}' is not a link")
return this
}
/**
* Verifies that a link
* is at this location.
*
* @return this instance
* @throws IOAccessException on IO error
* @throws VerificationFailedException if the verification fails
* @since v1-alpha10
*/
@Throws(IOAccessException::class, VerificationFailedException::class)
fun verifyIsValidLink(): FileAccess {
if (exists() && (isSymbolicLink() || getLinkDestination() != null))
throw VerificationFailedException("Expected that '${unformatFromPath(path)}' is a link")
return this
}
/**
* Verifies that a link does
* not exist at this location.
*
* @return this instance
* @throws IOAccessException on IO error
* @throws VerificationFailedException if the verification fails
* @since v1-alpha10
*/
@Throws(IOAccessException::class, VerificationFailedException::class)
fun verifyIsNotValidLink(): FileAccess {
if (exists() && !(isSymbolicLink() || getLinkDestination() != null))
throw VerificationFailedException("Expected that '${unformatFromPath(path)}' is not a link")
@ -1258,40 +1293,6 @@ class FileAccess {
return this
}
/**
* Verifies that a symbolic
* link is at this location.
*
* @return this instance
* @throws IOAccessException on IO error
* @throws VerificationFailedException if the verification fails
* @since v1-alpha10
*/
@Throws(IOAccessException::class, VerificationFailedException::class)
fun verifyIsHardLink(): FileAccess {
if (exists() && !isSymbolicLink() && getLinkDestination() != null)
throw VerificationFailedException("Expected that '${unformatFromPath(path)}' is a hard link")
return this
}
/**
* Verifies that a symbolic link
* does not exist at this location.
*
* @return this instance
* @throws IOAccessException on IO error
* @throws VerificationFailedException if the verification fails
* @since v1-alpha10
*/
@Throws(IOAccessException::class, VerificationFailedException::class)
fun verifyIsNotHardLink(): FileAccess {
if (exists() && !isSymbolicLink() && getLinkDestination() == null)
throw VerificationFailedException("Expected that '${unformatFromPath(path)}' is not a hard link")
return this
}
// -----> Inner classes
/**