File tree 2 files changed +9
-7
lines changed
tzdbOnFilesystem/src/internal 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -20,22 +20,22 @@ private val tzdb = runCatching { TzdbOnFilesystem() }
20
20
21
21
@OptIn(ExperimentalForeignApi ::class )
22
22
private fun getTimezoneFromEtcTimezone (): String? {
23
- val timezoneContent = Path .fromString(" / etc/timezone" ).readBytes()?.toKString()?.trim() ? : return null
24
- val zoneId = chaseSymlinks(" / usr/share/zoneinfo/$timezoneContent " )
23
+ val timezoneContent = Path .fromString(" ${root} etc/timezone" ).readBytes()?.toKString()?.trim() ? : return null
24
+ val zoneId = chaseSymlinks(" ${root} usr/share/zoneinfo/$timezoneContent " )
25
25
?.splitTimeZonePath()?.second?.toString()
26
26
? : return null
27
27
28
- val zoneInfoBytes = Path .fromString(" / usr/share/zoneinfo/$zoneId " ).readBytes() ? : return null
29
- val localtimeBytes = Path .fromString(" / etc/localtime" ).readBytes() ? : return null
28
+ val zoneInfoBytes = Path .fromString(" ${root} usr/share/zoneinfo/$zoneId " ).readBytes() ? : return null
29
+ val localtimeBytes = Path .fromString(" ${root} etc/localtime" ).readBytes() ? : return null
30
30
31
31
if (! localtimeBytes.contentEquals(zoneInfoBytes)) {
32
32
val displayTimezone = when (timezoneContent) {
33
33
zoneId -> " '$zoneId '"
34
34
else -> " '$timezoneContent ' (resolved to '$zoneId ')"
35
35
}
36
36
throw IllegalTimeZoneException (
37
- " Timezone mismatch: / etc/timezone specifies $displayTimezone " +
38
- " but / etc/localtime content differs from / usr/share/zoneinfo/$zoneId "
37
+ " Timezone mismatch: ${root} etc/timezone specifies $displayTimezone " +
38
+ " but ${root} etc/localtime content differs from ${root} usr/share/zoneinfo/$zoneId "
39
39
)
40
40
}
41
41
Original file line number Diff line number Diff line change @@ -47,7 +47,9 @@ internal fun tzdbPaths(defaultTzdbPath: Path?) = sequence {
47
47
currentSystemTimeZonePath?.splitTimeZonePath()?.first?.let { yield (it) }
48
48
}
49
49
50
- internal val currentSystemTimeZonePath get() = chaseSymlinks(" /etc/localtime" )
50
+ internal var root: String = " /"
51
+
52
+ internal val currentSystemTimeZonePath get() = chaseSymlinks(" ${root} etc/localtime" )
51
53
52
54
/* *
53
55
* Given a path like `/usr/share/zoneinfo/Europe/Berlin`, produces `/usr/share/zoneinfo to Europe/Berlin`.
You can’t perform that action at this time.
0 commit comments