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

commonMain.ext.File.kt Maven / Gradle / Ivy

There is a newer version: 0.4.1
Show newest version
package dev.petuska.klip.core.ext

/**
 * Multiplatform wrapper over java.io.File API
 */
public expect class File(path: String) {
  /**
   * Retrieves parent file
   */
  public fun getParentFile(): File?

  /**
   * Returns local path to this file
   */
  public fun getPath(): String

  /**
   * Returns absolute path to this file
   */
  public fun getAbsolutePath(): String

  /**
   * Recursively makes all directories up to this directory file
   */
  public fun mkdirs(): Boolean

  /**
   * Checks if the file exists
   */
  public fun exists(): Boolean

  /**
   * Checks if the file is directory
   */
  public fun isDirectory(): Boolean

  override fun toString(): String
}

/**
 * Native file separator for the platform (thanks a bunch, windows...)
 */
public expect val File.separator: String

/**
 * Native newline separator for the platform (thanks a bunch, windows...)
 */
public expect val File.newline: String

/**
 * Writes text to file creating it if needed and fully overwriting any previous content
 */
public expect fun File.writeText(text: String)

/**
 * Reads this file as text
 */
public expect fun File.readText(): String

/**
 * Deletes this file and any subdirectories recursively
 */
public expect fun File.deleteRecursively(): Boolean




© 2015 - 2025 Weber Informatics LLC | Privacy Policy