<commit_before>package com.satsumasoftware.timetable.db

import android.Manifest
import android.app.Activity
import android.content.pm.PackageManager
import android.os.Environment
import android.support.v4.app.ActivityCompat
import android.util.Log
import com.satsumasoftware.timetable.BuildConfig
import org.threeten.bp.LocalDate
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.nio.channels.FileChannel

object DatabaseUtils {

    private const val LOG_TAG = "DatabaseUtils"

    private const val DB_PATH = "data/data/" + BuildConfig.APPLICATION_ID + "/databases/" +
            TimetableDbHelper.DATABASE_NAME

    @JvmStatic private val DEFAULT_EXPORT_DIRECTORY =
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)

    @JvmStatic private val DEFAULT_EXPORT_FILENAME =
            "Timetables-Exported-" + LocalDate.now().toString()


    @JvmStatic
    fun exportDatabase(activity: Activity): Boolean {
        val localDatabase = File(DB_PATH)
        val exportedFile = File(DEFAULT_EXPORT_DIRECTORY, DEFAULT_EXPORT_FILENAME)

        if (!localDatabase.exists()) {
            Log.wtf(LOG_TAG, "Local database doesn't exist?!")<commit_msg>Use date and time in exported db file name<commit_after>package com.satsumasoftware.timetable.db

import android.Manifest
import android.app.Activity
import android.content.pm.PackageManager
import android.os.Environment
import android.support.v4.app.ActivityCompat
import android.util.Log
import com.satsumasoftware.timetable.BuildConfig
import org.threeten.bp.LocalDateTime
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.nio.channels.FileChannel

object DatabaseUtils {

    private const val LOG_TAG = "DatabaseUtils"

    private const val DB_PATH = "data/data/" + BuildConfig.APPLICATION_ID + "/databases/" +
            TimetableDbHelper.DATABASE_NAME

    @JvmStatic private val DEFAULT_EXPORT_DIRECTORY =
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)

    @JvmStatic private val DEFAULT_EXPORT_FILENAME =
            "Timetables-Exported-" + LocalDateTime.now().toString()


    @JvmStatic
    fun exportDatabase(activity: Activity): Boolean {
        val localDatabase = File(DB_PATH)
        val exportedFile = File(DEFAULT_EXPORT_DIRECTORY, DEFAULT_EXPORT_FILENAME)

        if (!localDatabase.exists()) {
            Log.wtf(LOG_TAG, "Local database doesn't exist?!")
{'fraction_non_alphanumeric': 0.08057439170323095, 'fraction_numerical': 0.0007977662544874351, 'mean_word_length': 4.2578616352201255, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1373213', 'n_tokens_mistral': 730, 'n_tokens_neox': 687, 'n_words': 149}