Replaced hardcoded separator by OS dependant appropach
This commit is contained in:
parent
2a12c3e883
commit
93a1ef3240
@ -11,7 +11,7 @@ val String.md5: String
|
|||||||
|
|
||||||
val String.dirName: String
|
val String.dirName: String
|
||||||
get() {
|
get() {
|
||||||
val parts = this.split("/")
|
val parts = this.split(systemSeparator)
|
||||||
|
|
||||||
return if (parts.isNotEmpty())
|
return if (parts.isNotEmpty())
|
||||||
parts.last()
|
parts.last()
|
||||||
@ -21,11 +21,11 @@ val String.dirName: String
|
|||||||
|
|
||||||
val String.dirPath: String
|
val String.dirPath: String
|
||||||
get() {
|
get() {
|
||||||
val parts = this.split("/").toMutableList()
|
val parts = this.split(systemSeparator).toMutableList()
|
||||||
|
|
||||||
return if (parts.count() > 1) {
|
return if (parts.count() > 1) {
|
||||||
parts.removeLast()
|
parts.removeLast()
|
||||||
parts.joinToString("/")
|
parts.joinToString(systemSeparator)
|
||||||
} else
|
} else
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
7
src/main/kotlin/app/extensions/SystemUtils.kt
Normal file
7
src/main/kotlin/app/extensions/SystemUtils.kt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package app.extensions
|
||||||
|
|
||||||
|
import java.nio.file.FileSystems
|
||||||
|
|
||||||
|
val systemSeparator: String by lazy {
|
||||||
|
FileSystems.getDefault().separator
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package app.git
|
package app.git
|
||||||
|
|
||||||
import app.TempFilesManager
|
import app.TempFilesManager
|
||||||
|
import app.extensions.systemSeparator
|
||||||
import dagger.assisted.Assisted
|
import dagger.assisted.Assisted
|
||||||
import dagger.assisted.AssistedInject
|
import dagger.assisted.AssistedInject
|
||||||
import org.eclipse.jgit.diff.ContentSource
|
import org.eclipse.jgit.diff.ContentSource
|
||||||
@ -74,13 +75,10 @@ class RawFileManager @AssistedInject constructor(
|
|||||||
entry: DiffEntry,
|
entry: DiffEntry,
|
||||||
side: DiffEntry.Side
|
side: DiffEntry.Side
|
||||||
): EntryContent.ImageBinary {
|
): EntryContent.ImageBinary {
|
||||||
println("Data's size is ${ldr.size}")
|
|
||||||
|
|
||||||
val tempDir = tempFilesManager.tempDir
|
val tempDir = tempFilesManager.tempDir
|
||||||
|
|
||||||
val tempFile = createTempFile(tempDir, prefix = "${entry.newPath.replace("/", "_")}_${side.name}")
|
val tempFile = createTempFile(tempDir, prefix = "${entry.newPath.replace(systemSeparator, "_")}_${side.name}")
|
||||||
tempFile.toFile().deleteOnExit()
|
tempFile.toFile().deleteOnExit()
|
||||||
println("Temp file generated: ${tempFile.absolutePathString()}")
|
|
||||||
|
|
||||||
val out = FileOutputStream(tempFile.toFile())
|
val out = FileOutputStream(tempFile.toFile())
|
||||||
out.use {
|
out.use {
|
||||||
|
Loading…
Reference in New Issue
Block a user