2024-03-08 18:44:24 +01:00
|
|
|
package fr.acinq.lightning.bin
|
|
|
|
|
|
|
|
import app.cash.sqldelight.db.SqlDriver
|
|
|
|
import app.cash.sqldelight.driver.native.NativeSqliteDriver
|
2024-03-18 17:21:03 +01:00
|
|
|
import fr.acinq.phoenix.db.PhoenixDatabase
|
2024-03-08 18:44:24 +01:00
|
|
|
import kotlinx.cinterop.ExperimentalForeignApi
|
|
|
|
import kotlinx.cinterop.toKString
|
|
|
|
import okio.Path
|
|
|
|
import okio.Path.Companion.toPath
|
|
|
|
import platform.posix.getenv
|
|
|
|
import platform.posix.setenv
|
|
|
|
|
|
|
|
@OptIn(ExperimentalForeignApi::class)
|
|
|
|
actual val homeDirectory: Path = setenv("KTOR_LOG_LEVEL", "WARN", 1).let { getenv("HOME")?.toKString()!!.toPath() }
|
|
|
|
|
|
|
|
actual fun createAppDbDriver(dir: Path): SqlDriver {
|
2024-03-18 17:21:03 +01:00
|
|
|
return NativeSqliteDriver(PhoenixDatabase.Schema, "phoenix.db",
|
2024-03-08 18:44:24 +01:00
|
|
|
onConfiguration = { it.copy(extendedConfig = it.extendedConfig.copy(basePath = dir.toString())) }
|
|
|
|
)
|
|
|
|
}
|