qwen3.6:35b's first attempt, does not compile (yet).

This commit is contained in:
me committed 2026-11-02 15:28:46 -07:00
1 parent eeda4a18c5
commit 337403721b
17 files changed
+1486 -40

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
package com.hyperling.weather
import java.io.File
/**
* File-based local storage manager for location entries (JVM/Desktop).
*/
class JvmStorageBackend : StorageBackend {
private val STORAGE_DIR = File(System.getProperty("user.home"), ".nomadic-weather")
private val STORAGE_FILE = File(STORAGE_DIR, "locations.json")
init {
STORAGE_DIR.mkdirs()
}
override fun load(): List<LocationEntry> {
return try {
if (STORAGE_FILE.exists()) {
LocationSerializer.jsonToLocations(STORAGE_FILE.readText())
} else emptyList()
} catch (e: Exception) {
emptyList()
}
}
override fun save(locations: List<LocationEntry>) {
try {
STORAGE_DIR.mkdirs()
STORAGE_FILE.writeText(LocationSerializer.locationsToJson(locations))
} catch (e: Exception) {}
}
override fun saveOne(location: LocationEntry) {
val existing = load().toMutableList()
val idx = existing.indexOfFirst { it == location }
if (idx >= 0) existing[idx] = location
else {
if (existing.size >= 8) existing.removeAt(0)
existing.add(location)
}
save(existing)
}
override fun delete(id: Long) {
save(load().filter { it.id != id })
}
}
actual fun LocationStorage.getStorage(): StorageBackend = JvmStorageBackend()
+6
View File
@@ -0,0 +1,6 @@
package com.hyperling.weather
import io.ktor.client.engine.cio.CIO
import io.ktor.client.engine.HttpClientEngine
actual fun getEngine(): HttpClientEngine = CIO.create()
+59
View File
@@ -0,0 +1,59 @@
package com.hyperling.weather
import java.io.File
/**
* JVM Implementation of StorageBackend for Desktop use.
*/
class JvmStorageBackendImpl : StorageBackend {
private val STORAGE_DIR = File(System.getProperty("user.home"), ".nomadic-weather")
private val STORAGE_FILE = File(STORAGE_DIR, "locations.json")
init {
STORAGE_DIR.mkdirs()
}
override fun load(): List<LocationEntry> {
return try {
if (STORAGE_FILE.exists()) LocationSerializer.jsonToLocations(STORAGE_FILE.readText()) else emptyList()
} catch (e: Exception) {
emptyList()
}
}
override fun save(locations: List<LocationEntry>) {
try {
STORAGE_DIR.mkdirs()
STORAGE_FILE.writeText(LocationSerializer.locationsToJson(locations))
} catch (e: Exception) {}
}
override fun saveOne(location: LocationEntry) {
val ex = load().toMutableList()
val idx = ex.indexOfFirst { it == location }
if (idx >= 0) ex[idx] = location
else {
if (ex.size >= 8) ex.removeAt(0)
ex.add(location)
}
save(ex)
}
override fun delete(id: Long) {
save(load().filter { it.id != id })
}
}
/**
* JVM-specific platform initialization.
*/
class JvmPlatformInit : PlatformInit {
override fun initialize() {
val dir = File(System.getProperty("user.home"), ".nomadic-weather")
if (!dir.exists()) dir.mkdirs()
println("Nomadic Weather Desktop Initialized")
}
}
actual fun getPlatformStorage(): StorageBackend = JvmStorageBackendImpl()
actual fun getPlatformInit(): PlatformInit = JvmPlatformInit()