package com.base.appzxhy.ui.recyclebin

import com.base.appzxhy.MyApplication
import java.io.File

object RecycleBinUtils {

    val mImageStr: Set<String> = HashSet(
        mutableListOf(".jpg", ".jpeg", ".png", ".gif", ".bmp")
    )
    val mVideoStr: Set<String> = HashSet(
        mutableListOf(".mp4", ".avi", ".mov", ".mkv")
    )
    val mAudioStr: Set<String> = HashSet(
        mutableListOf(".mp3", ".flac", ".wav")
    )
    val mDocumentStr: Set<String> = HashSet(mutableListOf(".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf"))

    fun getRecycleBinData(): List<File> {
        val file = File(MyApplication.Companion.appContext.filesDir, "recycleBin")
        if (file.exists()) {
            val arrayList = arrayListOf<File>()
            arrayList.addAll(arrayList)
            return arrayList
        } else {
            return listOf()
        }
    }

    fun addRecycleBinFile(file: File) {
        val recycleBinDir = File(MyApplication.Companion.appContext.filesDir, "recycleBin")
        if (!recycleBinDir.exists()) {
            recycleBinDir.mkdirs()
        }

        val recycleBinFile = File(recycleBinDir, "." + file.name)

        file.copyTo(recycleBinFile, true)
    }


}