1 /* 2 * Copyright (C) 2021 Square, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package okio 17 18 import kotlin.time.Duration 19 isBrowsernull20actual fun isBrowser() = false 21 22 actual fun isWasm() = true 23 24 actual interface Clock { 25 actual fun now(): Instant 26 } 27 28 actual class Instant( 29 private val epochMilliseconds: Long, 30 ) : Comparable<Instant> { 31 actual val epochSeconds: Long 32 get() = epochMilliseconds / 1_000L 33 plusnull34 actual operator fun plus(duration: Duration) = 35 Instant(epochMilliseconds + duration.inWholeMilliseconds) 36 37 actual operator fun minus(duration: Duration) = 38 Instant(epochMilliseconds - duration.inWholeMilliseconds) 39 40 override fun compareTo(other: Instant) = 41 epochMilliseconds.compareTo(other.epochMilliseconds) 42 } 43 44 actual fun fromEpochSeconds(epochSeconds: Long) = 45 Instant(epochSeconds * 1_000L) 46 47 actual fun fromEpochMilliseconds(epochMilliseconds: Long) = 48 Instant(epochMilliseconds) 49 50 actual val FileSystem.isFakeFileSystem: Boolean 51 get() = false 52 53 actual val FileSystem.allowSymlinks: Boolean 54 get() = error("unexpected call") 55 56 actual val FileSystem.allowReadsWhileWriting: Boolean 57 get() = error("unexpected call") 58 59 actual var FileSystem.workingDirectory: Path 60 get() = error("unexpected call") 61 set(_) = error("unexpected call") 62