From 4ffe9bbaa52e09721dd155dd3fb30108bec47d31 Mon Sep 17 00:00:00 2001 From: euxane Date: Wed, 18 Sep 2024 23:41:13 +0200 Subject: utils/files: fix isParentOf null file handling --- app/src/main/java/org/pacien/tincapp/utils/Files.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/org/pacien/tincapp/utils/Files.kt b/app/src/main/java/org/pacien/tincapp/utils/Files.kt index 8eda328..0228785 100644 --- a/app/src/main/java/org/pacien/tincapp/utils/Files.kt +++ b/app/src/main/java/org/pacien/tincapp/utils/Files.kt @@ -47,15 +47,16 @@ fun File.makePublic() { } fun File.isParentOf(childCandidate: File, strict: Boolean = true): Boolean { - var parentOfChild = childCandidate.canonicalFile + var parentOfChild: File? = childCandidate.canonicalFile if (strict) - parentOfChild = parentOfChild.parentFile + parentOfChild = parentOfChild?.parentFile while (parentOfChild != null) { if (parentOfChild.equals(canonicalFile)) return true parentOfChild = parentOfChild.parentFile } + return false } -- cgit v1.2.3