File tree 3 files changed +12
-12
lines changed
tzdbOnFilesystem/src/internal 3 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -22,22 +22,22 @@ private val tzdb = runCatching { TzdbOnFilesystem() }
22
22
// See: https://github.com/Kotlin/kotlinx-datetime/issues/430
23
23
@OptIn(ExperimentalForeignApi ::class )
24
24
private fun getTimezoneFromEtcTimezone (): String? {
25
- val timezoneContent = Path .fromString(" ${root } etc/timezone" ).readBytes()?.toKString()?.trim() ? : return null
26
- val zoneId = chaseSymlinks(" ${root } usr/share/zoneinfo/$timezoneContent " )
25
+ val timezoneContent = Path .fromString(" ${systemTimezoneSearchRoot } etc/timezone" ).readBytes()?.toKString()?.trim() ? : return null
26
+ val zoneId = chaseSymlinks(" ${systemTimezoneSearchRoot } usr/share/zoneinfo/$timezoneContent " )
27
27
?.splitTimeZonePath()?.second?.toString()
28
28
? : return null
29
29
30
- val zoneInfoBytes = Path .fromString(" ${root } usr/share/zoneinfo/$zoneId " ).readBytes() ? : return null
31
- val localtimeBytes = Path .fromString(" ${root } etc/localtime" ).readBytes() ? : return null
30
+ val zoneInfoBytes = Path .fromString(" ${systemTimezoneSearchRoot } usr/share/zoneinfo/$zoneId " ).readBytes() ? : return null
31
+ val localtimeBytes = Path .fromString(" ${systemTimezoneSearchRoot } etc/localtime" ).readBytes() ? : return null
32
32
33
33
if (! localtimeBytes.contentEquals(zoneInfoBytes)) {
34
34
val displayTimezone = when (timezoneContent) {
35
35
zoneId -> " '$zoneId '"
36
36
else -> " '$timezoneContent ' (resolved to '$zoneId ')"
37
37
}
38
38
throw IllegalTimeZoneException (
39
- " Timezone mismatch: ${root } etc/timezone specifies $displayTimezone " +
40
- " but ${root } etc/localtime content differs from ${root } usr/share/zoneinfo/$zoneId "
39
+ " Timezone mismatch: ${systemTimezoneSearchRoot } etc/timezone specifies $displayTimezone " +
40
+ " but ${systemTimezoneSearchRoot } etc/localtime content differs from ${systemTimezoneSearchRoot } usr/share/zoneinfo/$zoneId "
41
41
)
42
42
}
43
43
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ package kotlinx.datetime.test
7
7
8
8
import kotlinx.datetime.IllegalTimeZoneException
9
9
import kotlinx.datetime.TimeZone
10
- import kotlinx.datetime.internal.root
10
+ import kotlinx.datetime.internal.systemTimezoneSearchRoot
11
11
import kotlin.test.Test
12
12
import kotlin.test.assertEquals
13
13
import kotlin.test.assertFailsWith
@@ -73,12 +73,12 @@ class TimeZoneNativeTest {
73
73
const val RESOURCES = " ./linux/test/time-zone-native-test-resources/"
74
74
75
75
private fun withFakeRoot (fakeRoot : String , action : () -> Unit ) {
76
- val defaultRoot = root
77
- root = fakeRoot
76
+ val defaultRoot = systemTimezoneSearchRoot
77
+ systemTimezoneSearchRoot = fakeRoot
78
78
try {
79
79
action()
80
80
} finally {
81
- root = defaultRoot
81
+ systemTimezoneSearchRoot = defaultRoot
82
82
}
83
83
}
84
84
}
Original file line number Diff line number Diff line change @@ -47,9 +47,9 @@ internal fun tzdbPaths(defaultTzdbPath: Path?) = sequence {
47
47
currentSystemTimeZonePath?.splitTimeZonePath()?.first?.let { yield (it) }
48
48
}
49
49
50
- internal var root : String = " /"
50
+ internal var systemTimezoneSearchRoot : String = " /"
51
51
52
- internal val currentSystemTimeZonePath get() = chaseSymlinks(" ${root } etc/localtime" )
52
+ internal val currentSystemTimeZonePath get() = chaseSymlinks(" ${systemTimezoneSearchRoot } etc/localtime" )
53
53
54
54
/* *
55
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