Skip to content

Commit 7589116

Browse files
authored
Merge pull request #17 from ItzNotABug/case-sensitive-search
Support `ignoreCase`
2 parents 0c06c97 + e633be1 commit 7589116

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

dfc/src/main/java/com/lazygeniouz/dfc/file/DocumentFileCompat.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,12 @@ abstract class DocumentFileCompat constructor(
7979
/**
8080
* Find a File against the given name.
8181
*
82-
*
8382
* Do not use this if you are going to call `listFiles()` again on the same
84-
* DocumentFileCompat object because this method internally searches same list.
83+
* [DocumentFileCompat] object because this method internally searches same list.
8584
*
8685
* Multiple calls to `listFiles()` can have a performance hit.
8786
*/
88-
abstract fun findFile(name: String): DocumentFileCompat?
87+
abstract fun findFile(name: String, ignoreCase: Boolean = false): DocumentFileCompat?
8988

9089
/**
9190
* Copy a document to a given Uri.

dfc/src/main/java/com/lazygeniouz/dfc/file/internals/RawDocumentFileCompat.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ internal class RawDocumentFileCompat constructor(context: Context, var file: Fil
112112
}
113113

114114
// Return a file if exists, else **null**
115-
override fun findFile(name: String): DocumentFileCompat? {
115+
override fun findFile(name: String, ignoreCase: Boolean): DocumentFileCompat? {
116116
return listFiles().firstOrNull { file -> file.name.isNotEmpty() && file.name == name }
117117
}
118118

dfc/src/main/java/com/lazygeniouz/dfc/file/internals/SingleDocumentFileCompat.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ internal class SingleDocumentFileCompat(
6363
*
6464
* @throws UnsupportedOperationException
6565
*/
66-
override fun findFile(name: String): DocumentFileCompat? {
66+
override fun findFile(name: String, ignoreCase: Boolean): DocumentFileCompat? {
6767
throw UnsupportedOperationException()
6868
}
6969

dfc/src/main/java/com/lazygeniouz/dfc/file/internals/TreeDocumentFileCompat.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ internal class TreeDocumentFileCompat constructor(
7070
/**
7171
* Return a file if exists, else **null**.
7272
*/
73-
override fun findFile(name: String): DocumentFileCompat? {
74-
return listFiles().firstOrNull { file -> file.name.isNotEmpty() && file.name == name }
73+
override fun findFile(name: String, ignoreCase: Boolean): DocumentFileCompat? {
74+
return listFiles().firstOrNull { file ->
75+
file.name.equals(name, ignoreCase = ignoreCase)
76+
}
7577
}
7678

7779
/**

0 commit comments

Comments
 (0)