Commit 07/08/2025

This commit is contained in:
2025-08-07 15:04:53 +07:00
parent 446f031535
commit eba4f7852e
12 changed files with 387 additions and 229 deletions

View File

@@ -9,6 +9,18 @@ class Codes {
companion object{
val audioFilePath = Path(System.getProperty("user.dir"), "audiofile")
private val validAudioExtensions = setOf("wav", "mp3")
private val KB_size = 1024 // 1 KB = 1024 bytes
private val MB_size = 1024 * KB_size // 1 MB = 1024 KB
private val GB_size = 1024 * MB_size // 1 GB = 1024 MB
fun SizeToString(size: Long) : String {
return when {
size >= GB_size -> String.format("%.2f GB", size.toDouble() / GB_size)
size >= MB_size -> String.format("%.2f MB", size.toDouble() / MB_size)
size >= KB_size -> String.format("%.2f KB", size.toDouble() / KB_size)
else -> "$size bytes"
}
}
fun getAudioFiles() : Array<String> {
val audioDir = audioFilePath.toFile()
if (!audioDir.exists()) {