package com.zxhy.fastfilemanagerpro.kokodata

import android.content.Context
import android.text.format.Formatter
import java.io.File
import java.text.SimpleDateFormat
import java.util.Locale

data class KoFileDatako(
    var name: String,
    var path: String,
    val timeE: String = "",
    var isSelect: Boolean = false,
    val sizeF: String = ""
) {
    companion object {
        fun KoFileDatako.toFile(): File {
            return File(path)
        }

        fun File.koFileDatako(context: Context): KoFileDatako {
            return KoFileDatako(
                name = name,
                timeE = timeE(),
                sizeF = sizeF(context),
                path = absolutePath
            )
        }

        fun File.timeE(): String {
            return SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH).format(lastModified())
        }

        fun File.sizeF(context: Context): String {
            return Formatter.formatFileSize(context, length())
        }
    }

}