Commit 06/08/2025
This commit is contained in:
@@ -1,12 +1,30 @@
|
||||
package somecodes
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import java.io.File
|
||||
import kotlin.io.path.Path
|
||||
|
||||
@Suppress("unused")
|
||||
class Codes {
|
||||
private val objectMapper = ObjectMapper()
|
||||
|
||||
companion object{
|
||||
val audioFilePath = Path(System.getProperty("user.dir"), "audiofile")
|
||||
private val validAudioExtensions = setOf("wav", "mp3")
|
||||
fun getAudioFiles() : Array<String> {
|
||||
val audioDir = audioFilePath.toFile()
|
||||
if (!audioDir.exists()) {
|
||||
audioDir.mkdirs() // Create directory if it doesn't exist
|
||||
}
|
||||
val ll = audioDir.listFiles()?.filter { it.isFile && validAudioExtensions.contains(it.extension) }?.map { it.name } ?: emptyList()
|
||||
return ll.toTypedArray()
|
||||
}
|
||||
|
||||
fun getaudioFileFullPath(filename: String) : String {
|
||||
if (ValidString(filename)) {
|
||||
val file = audioFilePath.resolve(filename)
|
||||
return file.toAbsolutePath().toString()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
fun ValidFile(s: String?) : Boolean {
|
||||
if (s!=null){
|
||||
|
||||
Reference in New Issue
Block a user