org.gerweck.scala.util.io.ExistingFile.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gerweck-utils-java6_2.11 Show documentation
Show all versions of gerweck-utils-java6_2.11 Show documentation
General utilies for Scala applications
The newest version!
package org.gerweck.scala.util.io
import java.nio.file.StandardOpenOption
/** Describes what to do if a target path already exists. */
sealed trait ExistingFile {
val openOpts: Seq[StandardOpenOption]
}
/** Contains options for handling existing files. */
object ExistingFile {
/** If the file exists, empty and overwrite it. */
case object Overwrite extends ExistingFile {
override final val openOpts =
Seq(StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)
}
/** If the file exists, fail the operation. */
case object Fail extends ExistingFile {
override final val openOpts =
Seq(StandardOpenOption.CREATE_NEW)
}
}