Skip to content

Commit

Permalink
Apply uchuhimo#68
Browse files Browse the repository at this point in the history
Thank you to @isXander for this contribution!
  • Loading branch information
nhubbard committed Feb 10, 2024
1 parent 58ed8f2 commit f65f9bc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/kotlin/com/nhubbard/konfig/source/Writer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ interface Writer {
* Save to specified file.
*
* @param file specified file
* @param mkdirs create all parent folders before writing
* @return a new source from specified file
*/
fun toFile(file: File) {
fun toFile(file: File, mkdirs: Boolean = false) {
if (mkdirs) file.parentFile.mkdirs()
file.outputStream().use {
toOutputStream(it)
}
Expand All @@ -55,8 +57,9 @@ interface Writer {
* Save to specified file path.
*
* @param file specified file path
* @param mkdirs create all parent folders before writing
*/
fun toFile(file: String) = toFile(File(file))
fun toFile(file: String, mkdirs: Boolean = false) = toFile(File(file), mkdirs)

/**
* Save to string.
Expand Down

0 comments on commit f65f9bc

Please sign in to comment.