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

jvmMain.platform.WindowsPlatformDriver.kt Maven / Gradle / Ivy

The newest version!
package org.openrndr.platform


import java.io.File

class WindowsPlatformDriver : PlatformDriver {

    override fun temporaryDirectory(): File {
        val directoryName = System.getProperty("java.io.tmpdir") + "OPENRNDR-" + randomID
        val file = File(directoryName)
        if (!file.exists()) {
            file.mkdirs()
        }
        return file
    }

    override fun cacheDirectory(programName: String): File {
        val f = File(".\\cache")
        if (!f.exists()) {
            val result = f.mkdirs()
            if (!result) {
                throw RuntimeException("could not create cache directory")
            }
        }
        return f
    }

    override fun supportDirectory(programName: String): File {
        return File(".")
    }

    companion object {
        val randomID: String

        init {
            val alphabet = charArrayOf(
                'a',
                'b',
                'd',
                'e',
                'f',
                'g',
                'h',
                'i',
                'j',
                'k',
                'l',
                'm',
                'n',
                'o',
                'p',
                'q',
                'r',
                's',
                't',
                'u',
                'v',
                'w',
                'x',
                'y',
                'z'
            )

            var id = ""
            for (i in 0..7) {
                id += alphabet[i]
            }

            randomID = id
        }

    }

    override fun path(): List {
        return System.getenv("PATH").split(";").map { File(it) }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy