aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreuxane2024-09-18 23:41:13 +0200
committereuxane2024-09-18 23:41:13 +0200
commit4ffe9bbaa52e09721dd155dd3fb30108bec47d31 (patch)
treed9ee83cb12e98295406774bd0b6c35db3660beb4
parenta63f59f2bc8f58140923abb459a98c595dbcb7f4 (diff)
downloadtincapp-4ffe9bbaa52e09721dd155dd3fb30108bec47d31.tar.gz
utils/files: fix isParentOf null file handling
-rw-r--r--app/src/main/java/org/pacien/tincapp/utils/Files.kt5
1 files changed, 3 insertions, 2 deletions
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() {
47} 47}
48 48
49fun File.isParentOf(childCandidate: File, strict: Boolean = true): Boolean { 49fun File.isParentOf(childCandidate: File, strict: Boolean = true): Boolean {
50 var parentOfChild = childCandidate.canonicalFile 50 var parentOfChild: File? = childCandidate.canonicalFile
51 51
52 if (strict) 52 if (strict)
53 parentOfChild = parentOfChild.parentFile 53 parentOfChild = parentOfChild?.parentFile
54 54
55 while (parentOfChild != null) { 55 while (parentOfChild != null) {
56 if (parentOfChild.equals(canonicalFile)) return true 56 if (parentOfChild.equals(canonicalFile)) return true
57 parentOfChild = parentOfChild.parentFile 57 parentOfChild = parentOfChild.parentFile
58 } 58 }
59
59 return false 60 return false
60} 61}
61 62