commit 09/02/2026
This commit is contained in:
@@ -5,6 +5,7 @@ import database.data.Soundbank
|
||||
import database.dbFunctions
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook
|
||||
import org.tinylog.Logger
|
||||
import java.io.File
|
||||
import java.sql.Connection
|
||||
import java.util.function.Consumer
|
||||
|
||||
@@ -236,6 +237,11 @@ class Table_Soundbank(connection: Connection) : dbFunctions<Soundbank>("soundban
|
||||
.sorted()
|
||||
}
|
||||
|
||||
/**
|
||||
* Find City by TAG
|
||||
* @param tag the city tag to search for
|
||||
* @return a list of Soundbank entries matching the city tag
|
||||
*/
|
||||
fun Find_City_By_TAG(tag: String) : List<Soundbank> {
|
||||
return List
|
||||
.filter {it.Category.equals(Category.City.name,true) }
|
||||
@@ -243,6 +249,11 @@ class Table_Soundbank(connection: Connection) : dbFunctions<Soundbank>("soundban
|
||||
.distinctBy { it.TAG }
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Airline Name by TAG
|
||||
* @param tag the airline code tag to search for
|
||||
* @return a list of Soundbank entries matching the airline code tag
|
||||
*/
|
||||
fun Find_AirlineName_By_TAG(tag: String) : List<Soundbank> {
|
||||
return List
|
||||
.filter {it.Category.equals(Category.Airplane_Name.name,true) }
|
||||
@@ -305,4 +316,34 @@ class Table_Soundbank(connection: Connection) : dbFunctions<Soundbank>("soundban
|
||||
.distinctBy { it.TAG }
|
||||
.sortedBy { it.TAG }
|
||||
}
|
||||
|
||||
class FileCheckResult{
|
||||
var validfile = arrayListOf<Soundbank>()
|
||||
var invalidfile = arrayListOf<Soundbank>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Soundbank path files existence
|
||||
* @param cb callback with FileCheckResult containing valid and invalid files
|
||||
*/
|
||||
fun FileCheck(cb: Consumer<FileCheckResult>){
|
||||
val result = FileCheckResult()
|
||||
// file wav must at least 10 kb
|
||||
val validfilesize = 10 * 1024; // 10 KB
|
||||
|
||||
for (sb in List){
|
||||
if (sb.Path.isBlank()) {
|
||||
result.invalidfile.add(sb)
|
||||
continue
|
||||
}
|
||||
val file = File(sb.Path)
|
||||
if (file.isFile && file.length() >= validfilesize) {
|
||||
// file size should at leat 10 kb
|
||||
result.validfile.add(sb)
|
||||
} else {
|
||||
result.invalidfile.add(sb)
|
||||
}
|
||||
}
|
||||
cb.accept(result)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user