package it.danieleverducci.openweddingapp.utils

import android.content.Context
import android.os.Environment
import it.danieleverducci.openweddingapp.Config
import java.io.File
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.*

class FileUtils {
    companion object {

        private fun getLocalImagePath(context: Context): File {
            return context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)!!
        }

        @Throws(IOException::class)
        fun createTempImageFile(context: Context): File {
            return File.createTempFile(UUID.randomUUID().toString(), null, context.cacheDir)
        }

        @Throws(IOException::class)
        fun createImageFile(context: Context): File {
            // Create an image file name
            val timeStamp: String = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date())
            val storageDir: File = getLocalImagePath(context)
            return File.createTempFile(
                "${Config.SAVED_FILES_BASE_NAME}_${timeStamp}_",".jpg", storageDir
            )
        }
    }
}