Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion dadb/src/main/kotlin/dadb/Dadb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import dadb.forwarding.TcpForwarder
import java.io.File
import java.nio.file.Files
import okio.*
import java.nio.file.FileSystems

interface Dadb : AutoCloseable {

Expand Down Expand Up @@ -250,6 +251,10 @@ interface Dadb : AutoCloseable {

private const val MIN_EMULATOR_PORT = 5555
private const val MAX_EMULATOR_PORT = 5683
private const val DEFAULT_MODE = 0b110100100
private val isPosixFs: Boolean by lazy {
FileSystems.getDefault().supportedFileAttributeViews().contains("posix")
}

@JvmStatic
@JvmOverloads
Expand Down Expand Up @@ -310,7 +315,11 @@ interface Dadb : AutoCloseable {
}

private fun readMode(file: File): Int {
return Files.getAttribute(file.toPath(), "unix:mode") as? Int ?: throw RuntimeException("Unable to read file mode")
if (!isPosixFs) {
return DEFAULT_MODE
}
val mode = Files.getAttribute(file.toPath(), "unix:mode") as? Int
return mode ?: DEFAULT_MODE
}
}
}