-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
380 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package me.ash.reader.ui.ext | ||
|
||
import java.io.BufferedReader | ||
import java.io.File | ||
import java.io.InputStream | ||
import java.io.InputStreamReader | ||
|
||
/** | ||
* Convert [InputStream] to [String]. | ||
*/ | ||
fun InputStream.readString(): String = | ||
BufferedReader(InputStreamReader(this)).useLines { lines -> | ||
val results = StringBuilder() | ||
lines.forEach { results.append(it) } | ||
results.toString() | ||
} | ||
|
||
/** | ||
* Delete a file or directory. | ||
*/ | ||
fun File.del() { | ||
if (this.isFile) { | ||
delete() | ||
return | ||
} | ||
this.listFiles()?.forEach { it.del() } | ||
delete() | ||
} | ||
|
||
fun File.mkDir() { | ||
val dirArray = this.absolutePath.split("/".toRegex()) | ||
var pathTemp = "" | ||
for (i in 1 until dirArray.size) { | ||
pathTemp = "$pathTemp/${dirArray[i]}" | ||
val newF = File("${dirArray[0]}$pathTemp") | ||
if (!newF.exists()) newF.mkdir() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.