Skip to content

Commit

Permalink
Added a file helper
Browse files Browse the repository at this point in the history
  • Loading branch information
kpgalligan committed Mar 26, 2022
1 parent 1f40a87 commit 617b629
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ internal actual class File(dirPath:String?=null, name:String){

actual val path:String

actual val exists: Boolean
get() = exists()

init {
if (dirPath == null || dirPath.isEmpty()) {
this.path = fixSlashes(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ internal actual class File(dirPath: String? = null, name: String) {

actual val path: String

actual val exists: Boolean
get() = exists()

init {
if (dirPath == null || dirPath.isEmpty()) {
this.path = fixSlashes(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ internal actual class File(dirPath:String? = null, name:String) {

actual val path: String

actual val exists: Boolean
get() = exists()

init {
if (dirPath == null || dirPath.isEmpty()) {
this.path = fixSlashes(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ package co.touchlab.sqliter

import co.touchlab.sqliter.internal.File

expect object DatabaseFileContext{
fun deleteDatabase(name: String, basePath:String? = null)
fun databasePath(databaseName:String, datapathPath:String?):String
internal fun databaseFile(databaseName:String, datapathPath:String?): File
expect object DatabaseFileContext {
fun deleteDatabase(name: String, basePath: String? = null)
fun databasePath(databaseName: String, datapathPath: String?): String
internal fun databaseFile(databaseName: String, datapathPath: String?): File
}


fun DatabaseFileContext.deleteDatabase(configuration: DatabaseConfiguration){
if(configuration.name != null)
fun DatabaseFileContext.deleteDatabase(configuration: DatabaseConfiguration) {
if (configuration.name != null)
deleteDatabase(configuration.name, configuration.extendedConfig.basePath)
}
}

fun DatabaseFileContext.databaseFileExists(name: String, basePath: String? = null): Boolean = databaseFile(name, basePath).exists
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package co.touchlab.sqliter.internal

internal expect class File {
val path: String
val exists: Boolean
}

0 comments on commit 617b629

Please sign in to comment.