Commit 25/09/2025
This commit is contained in:
@@ -12,6 +12,7 @@ import oshi.hardware.CentralProcessor
|
||||
import oshi.hardware.GlobalMemory
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.function.Consumer
|
||||
import kotlin.io.path.name
|
||||
@@ -21,6 +22,8 @@ import kotlin.io.path.name
|
||||
class Somecodes {
|
||||
companion object {
|
||||
val current_directory : String = System.getProperty("user.dir")
|
||||
val SoundbankResult_directory : Path = Path.of(current_directory,"SoundbankResult")
|
||||
val PagingResult_directory : Path = Path.of(current_directory,"PagingResult")
|
||||
val si = SystemInfo()
|
||||
val processor: CentralProcessor = si.hardware.processor
|
||||
val memory : GlobalMemory = si.hardware.memory
|
||||
@@ -29,6 +32,7 @@ class Somecodes {
|
||||
val dateformat2: DateTimeFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy")
|
||||
val timeformat1: DateTimeFormatter = DateTimeFormatter.ofPattern("hh:mm:ss")
|
||||
val timeformat2: DateTimeFormatter = DateTimeFormatter.ofPattern("hh:mm")
|
||||
val filenameformat: DateTimeFormatter = DateTimeFormatter.ofPattern("ddMMyyyy_HHmmss")
|
||||
const val KB_threshold = 1024.0
|
||||
const val MB_threshold = KB_threshold * 1024.0
|
||||
const val GB_threshold = MB_threshold * 1024.0
|
||||
@@ -354,6 +358,22 @@ class Somecodes {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a WAV file name with the current date and time.
|
||||
* The file name format is: [prefix]_ddMMyyyy_HHmmss_[postfix].wav
|
||||
* @param prefix An optional prefix to add before the date and time.
|
||||
* @param postfix An optional postfix to add after the date and time.
|
||||
* @return A string representing the generated WAV file name.
|
||||
*/
|
||||
fun Make_WAV_FileName(prefix: String, postfix: String) : String{
|
||||
val sb = StringBuilder()
|
||||
if (prefix.isNotEmpty()){sb.append(prefix).append("_")}
|
||||
sb.append(filenameformat.format(LocalDateTime.now()))
|
||||
if (postfix.isNotEmpty()){sb.append("_").append(postfix)}
|
||||
sb.append(".wav")
|
||||
return sb.toString()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user