Skip to content

Commit 617b629

Browse files
committed
Added a file helper
1 parent 1f40a87 commit 617b629

File tree

5 files changed

+19
-7
lines changed
  • sqliter-driver/src

5 files changed

+19
-7
lines changed

sqliter-driver/src/appleMain/kotlin/co/touchlab/sqliter/internal/File.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ internal actual class File(dirPath:String?=null, name:String){
2323

2424
actual val path:String
2525

26+
actual val exists: Boolean
27+
get() = exists()
28+
2629
init {
2730
if (dirPath == null || dirPath.isEmpty()) {
2831
this.path = fixSlashes(name)

sqliter-driver/src/linuxX64Main/kotlin/co/touchlab/sqliter/internal/File.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ internal actual class File(dirPath: String? = null, name: String) {
2323

2424
actual val path: String
2525

26+
actual val exists: Boolean
27+
get() = exists()
28+
2629
init {
2730
if (dirPath == null || dirPath.isEmpty()) {
2831
this.path = fixSlashes(name)

sqliter-driver/src/mingwMain/kotlin/co/touchlab/sqliter/internal/File.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ internal actual class File(dirPath:String? = null, name:String) {
2424

2525
actual val path: String
2626

27+
actual val exists: Boolean
28+
get() = exists()
29+
2730
init {
2831
if (dirPath == null || dirPath.isEmpty()) {
2932
this.path = fixSlashes(name)

sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/DatabaseFileContext.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ package co.touchlab.sqliter
1818

1919
import co.touchlab.sqliter.internal.File
2020

21-
expect object DatabaseFileContext{
22-
fun deleteDatabase(name: String, basePath:String? = null)
23-
fun databasePath(databaseName:String, datapathPath:String?):String
24-
internal fun databaseFile(databaseName:String, datapathPath:String?): File
21+
expect object DatabaseFileContext {
22+
fun deleteDatabase(name: String, basePath: String? = null)
23+
fun databasePath(databaseName: String, datapathPath: String?): String
24+
internal fun databaseFile(databaseName: String, datapathPath: String?): File
2525
}
2626

2727

28-
fun DatabaseFileContext.deleteDatabase(configuration: DatabaseConfiguration){
29-
if(configuration.name != null)
28+
fun DatabaseFileContext.deleteDatabase(configuration: DatabaseConfiguration) {
29+
if (configuration.name != null)
3030
deleteDatabase(configuration.name, configuration.extendedConfig.basePath)
31-
}
31+
}
32+
33+
fun DatabaseFileContext.databaseFileExists(name: String, basePath: String? = null): Boolean = databaseFile(name, basePath).exists

sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/internal/File.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ package co.touchlab.sqliter.internal
22

33
internal expect class File {
44
val path: String
5+
val exists: Boolean
56
}

0 commit comments

Comments
 (0)