Remove never working hard link detection
This commit is contained in:
parent
0f49fff498
commit
6389aaa5d0
1 changed files with 43 additions and 42 deletions
|
@ -490,10 +490,10 @@ class FileAccess {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the destination of
|
* Returns the destination
|
||||||
* this symbolic or hard link.
|
* 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
|
* @throws IOAccessException on IO error
|
||||||
* @since v1-alpha10
|
* @since v1-alpha10
|
||||||
*/
|
*/
|
||||||
|
@ -504,6 +504,7 @@ class FileAccess {
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
when (exception) {
|
when (exception) {
|
||||||
is NotLinkException, is UnsupportedOperationException -> null
|
is NotLinkException, is UnsupportedOperationException -> null
|
||||||
|
is IOException -> throw IOAccessException("Failed to get the link destination for '${unformatFromPath(path)}'", exception)
|
||||||
else -> throw exception
|
else -> throw exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1098,8 +1099,8 @@ class FileAccess {
|
||||||
* @since v1-alpha10
|
* @since v1-alpha10
|
||||||
*/
|
*/
|
||||||
@Throws(IOAccessException::class, VerificationFailedException::class)
|
@Throws(IOAccessException::class, VerificationFailedException::class)
|
||||||
fun verifyExists(): FileAccess {
|
fun verifyExists(noFollowSymbolicLink: Boolean = false): FileAccess {
|
||||||
if (!exists())
|
if (!exists(noFollowSymbolicLink = noFollowSymbolicLink))
|
||||||
throw VerificationFailedException("Expected that something exists at '${unformatFromPath(path)}'")
|
throw VerificationFailedException("Expected that something exists at '${unformatFromPath(path)}'")
|
||||||
|
|
||||||
return this
|
return this
|
||||||
|
@ -1115,8 +1116,8 @@ class FileAccess {
|
||||||
* @since v1-alpha10
|
* @since v1-alpha10
|
||||||
*/
|
*/
|
||||||
@Throws(IOAccessException::class, VerificationFailedException::class)
|
@Throws(IOAccessException::class, VerificationFailedException::class)
|
||||||
fun verifyNotExists(): FileAccess {
|
fun verifyNotExists(noFollowSymbolicLink: Boolean = false): FileAccess {
|
||||||
if (exists())
|
if (exists(noFollowSymbolicLink = noFollowSymbolicLink))
|
||||||
throw VerificationFailedException("Expected that nothing exists at '${unformatFromPath(path)}'")
|
throw VerificationFailedException("Expected that nothing exists at '${unformatFromPath(path)}'")
|
||||||
|
|
||||||
return this
|
return this
|
||||||
|
@ -1201,7 +1202,7 @@ class FileAccess {
|
||||||
*/
|
*/
|
||||||
@Throws(IOAccessException::class, VerificationFailedException::class)
|
@Throws(IOAccessException::class, VerificationFailedException::class)
|
||||||
fun verifyIsLink(): FileAccess {
|
fun verifyIsLink(): FileAccess {
|
||||||
if (exists() && (isSymbolicLink() || getLinkDestination() != null))
|
if (exists() && isSymbolicLink())
|
||||||
throw VerificationFailedException("Expected that '${unformatFromPath(path)}' is a link")
|
throw VerificationFailedException("Expected that '${unformatFromPath(path)}' is a link")
|
||||||
|
|
||||||
return this
|
return this
|
||||||
|
@ -1218,6 +1219,40 @@ class FileAccess {
|
||||||
*/
|
*/
|
||||||
@Throws(IOAccessException::class, VerificationFailedException::class)
|
@Throws(IOAccessException::class, VerificationFailedException::class)
|
||||||
fun verifyIsNotLink(): FileAccess {
|
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))
|
if (exists() && !(isSymbolicLink() || getLinkDestination() != null))
|
||||||
throw VerificationFailedException("Expected that '${unformatFromPath(path)}' is not a link")
|
throw VerificationFailedException("Expected that '${unformatFromPath(path)}' is not a link")
|
||||||
|
|
||||||
|
@ -1258,40 +1293,6 @@ class FileAccess {
|
||||||
return this
|
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
|
// -----> Inner classes
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue