All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dbobjekts.codegen.configbuilders.ValidateFile.kt Maven / Gradle / Ivy

There is a newer version: 0.6.0-RC2
Show newest version
package com.dbobjekts.codegen.configbuilders

import com.dbobjekts.api.exception.CodeGenerationException
import java.nio.file.Files
import java.nio.file.Paths


object ValidateFile {

    operator fun invoke(str: String, isDir: Boolean = false): Boolean {
        try {
            val path = Paths.get(str)
            return Files.exists(path) && (isDir || Files.isRegularFile(path))
        } catch (e: Exception) {
            throw CodeGenerationException("Could not parse $str to a valid file: ${e.message}")
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy