Commit f129f666 authored by Vasily Romanikhin's avatar Vasily Romanikhin
Browse files

CPP-15607: remote-dev performance: utility method without additional checks

parent 22c90745
Branches unavailable Tags unavailable
No related merge requests found
Showing with 21 additions and 1 deletion
+21 -1
...@@ -201,7 +201,11 @@ fun Path.writeSafe(outConsumer: (OutputStream) -> Unit): Path { ...@@ -201,7 +201,11 @@ fun Path.writeSafe(outConsumer: (OutputStream) -> Unit): Path {
@Throws(IOException::class) @Throws(IOException::class)
fun Path.write(data: String): Path { fun Path.write(data: String): Path {
parent?.createDirectories() parent?.createDirectories()
return writeUnsafe(data)
}
@Throws(IOException::class)
fun Path.writeUnsafe(data: String): Path {
Files.write(this, data.toByteArray()) Files.write(this, data.toByteArray())
return this return this
} }
...@@ -300,4 +304,20 @@ fun sanitizeFileName(name: String, replacement: String? = "_", isTruncate: Boole ...@@ -300,4 +304,20 @@ fun sanitizeFileName(name: String, replacement: String? = "_", isTruncate: Boole
} }
val Path.isWritable: Boolean val Path.isWritable: Boolean
get() = Files.isWritable(this) get() = Files.isWritable(this)
\ No newline at end of file
fun isDirectory(attributes: BasicFileAttributes?): Boolean {
return attributes != null && attributes.isDirectory
}
fun isSymbolicLink(attributes: BasicFileAttributes?): Boolean {
return attributes != null && attributes.isSymbolicLink
}
fun Path.deleteRegularFile() {
try {
Files.delete(this)
}
catch (ignore: Exception) {
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment