Full Code of square/okio for AI

master 2db85b44210d cached
404 files
3.1 MB
824.9k tokens
199 symbols
1 requests
Download .txt
Showing preview only (3,295K chars total). Download the full file or copy to clipboard to get everything.
Repository: square/okio
Branch: master
Commit: 2db85b44210d
Files: 404
Total size: 3.1 MB

Directory structure:
gitextract_navft37t/

├── .buildscript/
│   ├── prepare_mkdocs.sh
│   └── restore_v1_docs.sh
├── .editorconfig
├── .gitattributes
├── .github/
│   ├── renovate.json5
│   └── workflows/
│       ├── .java-version
│       ├── build.yml
│       └── release.yaml
├── .gitignore
├── BUG-BOUNTY.md
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE.txt
├── README.md
├── android-test/
│   ├── README.md
│   ├── build.gradle.kts
│   ├── multidex-config.pro
│   └── src/
│       └── main/
│           ├── AndroidManifest.xml
│           └── res/
│               ├── values/
│               │   └── strings.xml
│               └── xml/
│                   └── network_security_config.xml
├── build-support/
│   ├── build.gradle.kts
│   ├── settings.gradle.kts
│   └── src/
│       └── main/
│           └── kotlin/
│               ├── BuildSupport.kt
│               ├── bom.kt
│               ├── jvm.kt
│               ├── kmp.kt
│               └── platforms.kt
├── build.gradle.kts
├── docs/
│   ├── code_of_conduct.md
│   ├── css/
│   │   ├── app.css
│   │   └── dokka-logo.css
│   ├── file_system.md
│   ├── index.md
│   ├── java_io_recipes.md
│   ├── multiplatform.md
│   ├── recipes.md
│   ├── releasing.md
│   └── security.md
├── gradle/
│   ├── libs.versions.toml
│   └── wrapper/
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── mkdocs.yml
├── okio/
│   ├── api/
│   │   └── okio.api
│   ├── build.gradle.kts
│   ├── jvm/
│   │   └── jmh/
│   │       ├── README.md
│   │       ├── build.gradle.kts
│   │       └── src/
│   │           └── jmh/
│   │               └── java/
│   │                   └── com/
│   │                       └── squareup/
│   │                           └── okio/
│   │                               └── benchmarks/
│   │                                   ├── AsyncTimeoutBenchmark.java
│   │                                   ├── BenchmarkUtils.kt
│   │                                   ├── BufferCursorSeekBenchmark.java
│   │                                   ├── BufferPerformanceBenchmark.java
│   │                                   ├── BufferUtf8Benchmark.java
│   │                                   ├── GetByteBenchmark.java
│   │                                   ├── HashFunctionBenchmark.java
│   │                                   ├── IndexOfElementBenchmark.java
│   │                                   ├── ReadByteStringBenchmark.java
│   │                                   ├── SegmentedByteStringBenchmark.java
│   │                                   ├── SelectBenchmark.java
│   │                                   ├── Utf8Benchmark.java
│   │                                   └── WriteHexadecimalBenchmark.java
│   └── src/
│       ├── appleMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── ByteString.kt
│       │           └── SegmentedByteString.kt
│       ├── appleNonMacosX64Main/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── NonMacosX64PosixVariant.kt
│       ├── appleTest/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── AppleByteStringTest.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── Base64.kt
│       │           ├── Buffer.kt
│       │           ├── BufferedSink.kt
│       │           ├── BufferedSource.kt
│       │           ├── ByteString.kt
│       │           ├── CommonPlatform.kt
│       │           ├── ExperimentalFileSystem.kt
│       │           ├── FileHandle.kt
│       │           ├── FileMetadata.kt
│       │           ├── FileSystem.kt
│       │           ├── ForwardingFileSystem.kt
│       │           ├── ForwardingSource.kt
│       │           ├── HashingSink.kt
│       │           ├── HashingSource.kt
│       │           ├── Okio.kt
│       │           ├── Options.kt
│       │           ├── Path.kt
│       │           ├── PeekSource.kt
│       │           ├── RealBufferedSink.kt
│       │           ├── RealBufferedSource.kt
│       │           ├── Segment.kt
│       │           ├── SegmentPool.kt
│       │           ├── SegmentedByteString.kt
│       │           ├── Sink.kt
│       │           ├── Socket.kt
│       │           ├── Source.kt
│       │           ├── Timeout.kt
│       │           ├── TypedOptions.kt
│       │           ├── Utf8.kt
│       │           ├── Util.kt
│       │           └── internal/
│       │               ├── -Utf8.kt
│       │               ├── Buffer.kt
│       │               ├── BufferedSource.kt
│       │               ├── ByteString.kt
│       │               ├── FileSystem.kt
│       │               ├── Path.kt
│       │               ├── RealBufferedSink.kt
│       │               ├── RealBufferedSource.kt
│       │               └── SegmentedByteString.kt
│       ├── commonTest/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── BufferCommonTest.kt
│       │           ├── BufferedSinkFactory.kt
│       │           ├── BufferedSourceFactory.kt
│       │           ├── ByteStringFactory.kt
│       │           ├── ByteStringMoreTests.kt
│       │           ├── ByteStringTest.kt
│       │           ├── CommonBufferTest.kt
│       │           ├── CommonBufferedSinkTest.kt
│       │           ├── CommonBufferedSourceTest.kt
│       │           ├── CommonOkioKotlinTest.kt
│       │           ├── CommonOptionsTest.kt
│       │           ├── CommonRealBufferedSinkTest.kt
│       │           ├── CommonRealBufferedSourceTest.kt
│       │           ├── ForwardingSourceTest.kt
│       │           ├── HashingSinkTest.kt
│       │           ├── HashingSourceTest.kt
│       │           ├── HashingTest.kt
│       │           ├── MockSink.kt
│       │           ├── OkioTesting.kt
│       │           ├── PathTest.kt
│       │           ├── TypedOptionsTest.kt
│       │           ├── UnsafeCursorTest.kt
│       │           └── Utf8KotlinTest.kt
│       ├── hashFunctions/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── internal/
│       │               ├── HashFunction.kt
│       │               ├── Hmac.kt
│       │               ├── Md5.kt
│       │               ├── Sha1.kt
│       │               ├── Sha256.kt
│       │               └── Sha512.kt
│       ├── jsMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── FileSystem.kt
│       │           ├── JsPlatform.kt
│       │           └── internal/
│       │               └── ByteStringJs.kt
│       ├── jvmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── -DeprecatedOkio.kt
│       │           ├── -DeprecatedUtf8.kt
│       │           ├── -JvmPlatform.kt
│       │           ├── AsyncTimeout.kt
│       │           ├── Buffer.kt
│       │           ├── BufferedSink.kt
│       │           ├── BufferedSource.kt
│       │           ├── ByteString.kt
│       │           ├── CipherSink.kt
│       │           ├── CipherSource.kt
│       │           ├── DeflaterSink.kt
│       │           ├── DeprecatedUpgrade.kt
│       │           ├── FileSystem.System.kt
│       │           ├── FileSystem.kt
│       │           ├── ForwardingSink.kt
│       │           ├── ForwardingSource.kt
│       │           ├── ForwardingTimeout.kt
│       │           ├── HashingSink.kt
│       │           ├── HashingSource.kt
│       │           ├── InflaterSource.kt
│       │           ├── JvmFileHandle.kt
│       │           ├── JvmOkio.kt
│       │           ├── JvmSystemFileSystem.kt
│       │           ├── NioFileSystemFileHandle.kt
│       │           ├── NioFileSystemWrappingFileSystem.kt
│       │           ├── NioSystemFileSystem.kt
│       │           ├── Path.kt
│       │           ├── Pipe.kt
│       │           ├── RealBufferedSink.kt
│       │           ├── RealBufferedSource.kt
│       │           ├── SegmentPool.kt
│       │           ├── SegmentedByteString.kt
│       │           ├── Sink.kt
│       │           ├── Throttler.kt
│       │           ├── Timeout.kt
│       │           └── internal/
│       │               ├── -Atomic.kt
│       │               ├── -JavaIo.kt
│       │               ├── -ZlibJvm.kt
│       │               ├── DefaultSocket.kt
│       │               ├── PipeSocket.kt
│       │               └── ResourceFileSystem.kt
│       ├── jvmTest/
│       │   ├── kotlin/
│       │   │   └── okio/
│       │   │       ├── AsyncSocket.kt
│       │   │       ├── AsyncTimeoutTest.kt
│       │   │       ├── AwaitSignalTest.kt
│       │   │       ├── BufferCursorKotlinTest.kt
│       │   │       ├── BufferCursorTest.kt
│       │   │       ├── BufferFactory.kt
│       │   │       ├── BufferKotlinTest.kt
│       │   │       ├── BufferTest.kt
│       │   │       ├── BufferedSinkJavaTest.kt
│       │   │       ├── BufferedSinkTest.kt
│       │   │       ├── BufferedSourceJavaTest.kt
│       │   │       ├── BufferedSourceTest.kt
│       │   │       ├── ByteStringJavaTest.kt
│       │   │       ├── ByteStringKotlinTest.kt
│       │   │       ├── CipherAlgorithm.kt
│       │   │       ├── CipherFactory.kt
│       │   │       ├── CipherSinkTest.kt
│       │   │       ├── CipherSourceTest.kt
│       │   │       ├── DeflateKotlinTest.kt
│       │   │       ├── DeflaterSinkTest.kt
│       │   │       ├── FileHandleFileSystemTest.kt
│       │   │       ├── FileLeakTest.kt
│       │   │       ├── FileSystemJavaTest.kt
│       │   │       ├── FixedLengthSourceTest.kt
│       │   │       ├── ForwardingTimeoutKotlinTest.kt
│       │   │       ├── ForwardingTimeoutTest.kt
│       │   │       ├── InflaterSourceTest.kt
│       │   │       ├── JimfsOkioRoundTripTest.kt
│       │   │       ├── JvmSystemFileSystemTest.kt
│       │   │       ├── JvmTest.kt
│       │   │       ├── JvmTesting.kt
│       │   │       ├── LargeStreamsTest.kt
│       │   │       ├── MessageDigestConsistencyTest.kt
│       │   │       ├── NioTest.kt
│       │   │       ├── OkioKotlinTest.kt
│       │   │       ├── OkioTest.kt
│       │   │       ├── PipeKotlinTest.kt
│       │   │       ├── PipeTest.kt
│       │   │       ├── ReadUtf8LineTest.kt
│       │   │       ├── SegmentSharingTest.kt
│       │   │       ├── SocketTest.kt
│       │   │       ├── SocketTimeoutTest.kt
│       │   │       ├── Stopwatch.kt
│       │   │       ├── TestUtil.kt
│       │   │       ├── ThrottlerTakeTest.kt
│       │   │       ├── ThrottlerTest.kt
│       │   │       ├── TimeoutFactory.kt
│       │   │       ├── TimeoutTest.kt
│       │   │       ├── Utf8Test.kt
│       │   │       ├── WaitUntilNotifiedTest.kt
│       │   │       ├── ZipBuilder.kt
│       │   │       ├── ZipFileSystemJavaTest.kt
│       │   │       └── internal/
│       │   │           ├── HmacTest.kt
│       │   │           ├── PriorityQueueTest.kt
│       │   │           ├── ResourceFileSystemTest.kt
│       │   │           └── SetBitsOrZeroTest.kt
│       │   └── resources/
│       │       └── okio/
│       │           └── resourcefilesystem/
│       │               ├── a.txt
│       │               ├── b/
│       │               │   └── b.txt
│       │               └── non-ascii/
│       │                   └── ギリシア神話/
│       │                       └── Ἰλιάς
│       ├── linuxMain/
│       │   ├── headers/
│       │   │   ├── README.md
│       │   │   ├── include/
│       │   │   │   └── uapi/
│       │   │   │       └── linux/
│       │   │   │           └── stat.h
│       │   │   └── okio_statx.h
│       │   └── kotlin/
│       │       └── okio/
│       │           └── LinuxPosixVariant.kt
│       ├── macosX64Main/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── MacosX64PosixVariant.kt
│       ├── mingwX64Main/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── Windows.kt
│       │           ├── WindowsFileHandle.kt
│       │           └── WindowsPosixVariant.kt
│       ├── nativeMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── Cinterop.kt
│       │           ├── DataProcessor.kt
│       │           ├── Deflater.kt
│       │           ├── DeflaterSink.kt
│       │           ├── FileSink.kt
│       │           ├── FileSource.kt
│       │           ├── FileSystem.kt
│       │           ├── Inflater.kt
│       │           ├── InflaterSource.kt
│       │           ├── PosixFileSystem.kt
│       │           ├── PosixVariant.kt
│       │           ├── SizetVariant.kt
│       │           └── internal/
│       │               ├── -ZlibNative.kt
│       │               └── CRC32.kt
│       ├── nativeTest/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── ByteStringCinteropTest.kt
│       │           ├── DeflaterSinkTest.kt
│       │           ├── DeflaterTest.kt
│       │           ├── InflateDeflateTest.kt
│       │           ├── InflaterSourceTest.kt
│       │           ├── InflaterTest.kt
│       │           └── NativeSystemFileSystemTest.kt
│       ├── nonAppleMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── ByteString.kt
│       │           └── SegmentedByteString.kt
│       ├── nonJsMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── internal/
│       │               └── ByteStringNonJs.kt
│       ├── nonJvmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── Buffer.kt
│       │           ├── BufferedSink.kt
│       │           ├── BufferedSource.kt
│       │           ├── ForwardingSource.kt
│       │           ├── HashingSink.kt
│       │           ├── HashingSource.kt
│       │           ├── NonJvmPlatform.kt
│       │           ├── Path.kt
│       │           ├── RealBufferedSink.kt
│       │           ├── RealBufferedSource.kt
│       │           ├── SegmentPool.kt
│       │           ├── Sink.kt
│       │           └── Timeout.kt
│       ├── nonJvmTest/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── NonJvmTesting.kt
│       ├── nonWasmTest/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── FakeFileSystemTest.kt
│       │           ├── ForwardingFileSystemTest.kt
│       │           └── UseTest.kt
│       ├── systemFileSystemMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── FileSystem.System.kt
│       ├── unixMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── UnixFileHandle.kt
│       │           └── UnixPosixVariant.kt
│       ├── wasmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── FileSystem.kt
│       │           └── WasmPlatform.kt
│       ├── zlibMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── Deflater.kt
│       │           ├── DeflaterSink.kt
│       │           ├── GzipSink.kt
│       │           ├── GzipSource.kt
│       │           ├── Inflater.kt
│       │           ├── InflaterSource.kt
│       │           ├── ZipFileSystem.kt
│       │           ├── ZlibOkio.kt
│       │           └── internal/
│       │               ├── -Zlib.kt
│       │               ├── CRC32.kt
│       │               ├── FixedLengthSource.kt
│       │               ├── ZipEntry.kt
│       │               └── ZipFiles.kt
│       └── zlibTest/
│           └── kotlin/
│               └── okio/
│                   ├── GzipKotlinTest.kt
│                   ├── GzipSinkTest.kt
│                   ├── GzipSourceTest.kt
│                   ├── ZipFileSystemGoTest.kt
│                   ├── ZipFileSystemTest.kt
│                   └── internal/
│                       ├── CRC32Test.kt
│                       └── DatePartsToEpochMillisTest.kt
├── okio-assetfilesystem/
│   ├── README.md
│   ├── api/
│   │   └── okio-assetfilesystem.api
│   ├── build.gradle.kts
│   └── src/
│       ├── androidTest/
│       │   ├── assets/
│       │   │   ├── dir/
│       │   │   │   └── nested.txt
│       │   │   ├── file.txt
│       │   │   └── moby10b.txt
│       │   └── kotlin/
│       │       └── okio/
│       │           └── assetfilesystem/
│       │               └── AssetFileSystemTest.kt
│       └── main/
│           └── kotlin/
│               └── okio/
│                   └── assetfilesystem/
│                       └── AssetFileSystem.kt
├── okio-bom/
│   └── build.gradle.kts
├── okio-fakefilesystem/
│   ├── README.md
│   ├── api/
│   │   └── okio-fakefilesystem.api
│   ├── build.gradle.kts
│   └── src/
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── fakefilesystem/
│       │               ├── FakeFileSystem.kt
│       │               └── FileMetadataCommon.kt
│       ├── jvmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── fakefilesystem/
│       │               └── FileMetadataJvm.kt
│       └── nonJvmMain/
│           └── kotlin/
│               └── okio/
│                   └── fakefilesystem/
│                       └── FileMetadataNonJvm.kt
├── okio-nodefilesystem/
│   ├── build.gradle.kts
│   └── src/
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── FileSink.kt
│       │           ├── FileSource.kt
│       │           ├── FsJs.kt
│       │           ├── NodeJsFileHandle.kt
│       │           └── NodeJsFileSystem.kt
│       └── commonTest/
│           └── kotlin/
│               └── okio/
│                   └── NodeJsFileSystemTest.kt
├── okio-testing-support/
│   ├── README.md
│   ├── build.gradle.kts
│   └── src/
│       ├── commonMain/
│       │   ├── kotlin/
│       │   │   └── okio/
│       │   │       ├── AbstractFileSystemTest.kt
│       │   │       ├── CloseBehavior.kt
│       │   │       ├── FakeClock.kt
│       │   │       ├── TestDirectory.kt
│       │   │       └── TestingCommon.kt
│       │   └── resources/
│       │       ├── go/
│       │       │   └── NOTICE
│       │       └── okio/
│       │           └── zipfilesystem/
│       │               ├── cannotReadZipWithSpanning.z01
│       │               └── cannotReadZipWithSpanning.z02
│       ├── jsMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── TestingJs.kt
│       ├── jvmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── TestExecutor.kt
│       │           └── TestingJvm.kt
│       ├── nativeMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── TestingNative.kt
│       ├── nonWasmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── TestingNonWasm.kt
│       ├── wasmJsMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── WasiEnvWasmJs.kt
│       ├── wasmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── TestingWasm.kt
│       └── wasmWasiMain/
│           └── kotlin/
│               └── okio/
│                   ├── WasiClock.kt
│                   ├── WasiEnv.kt
│                   └── internal/
│                       └── preview1/
│                           ├── Clockid.kt
│                           ├── Preview1Clock.kt
│                           └── Preview1Env.kt
├── okio-wasifilesystem/
│   ├── README.md
│   ├── build.gradle.kts
│   └── src/
│       ├── wasmWasiMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── FileSink.kt
│       │           ├── FileSource.kt
│       │           ├── WasiFileHandle.kt
│       │           ├── WasiFileSystem.kt
│       │           └── internal/
│       │               ├── ErrnoException.kt
│       │               ├── Wasi.kt
│       │               └── preview1/
│       │                   ├── Errno.kt
│       │                   ├── Fdflags.kt
│       │                   ├── Filetype.kt
│       │                   ├── LookupFlags.kt
│       │                   ├── OFlags.kt
│       │                   ├── Preview1.kt
│       │                   └── Rights.kt
│       └── wasmWasiTest/
│           └── kotlin/
│               └── okio/
│                   ├── WasiFileSystemPreopensTest.kt
│                   ├── WasiFileSystemTest.kt
│                   └── WasiTest.kt
├── samples/
│   ├── build.gradle.kts
│   └── src/
│       ├── jvmMain/
│       │   ├── java/
│       │   │   └── okio/
│       │   │       └── samples/
│       │   │           ├── BitmapEncoder.java
│       │   │           ├── ByteChannelSink.java
│       │   │           ├── ByteChannelSource.java
│       │   │           ├── ExploreCharsets.java
│       │   │           ├── FileChannelSink.java
│       │   │           ├── FileChannelSource.java
│       │   │           ├── GoldenValue.java
│       │   │           ├── Hashing.java
│       │   │           ├── Interceptors.java
│       │   │           ├── Randoms.java
│       │   │           ├── ReadFileLineByLine.java
│       │   │           ├── ReadFileLineByLine.kt
│       │   │           ├── ReadJavaIoFileLineByLine.java
│       │   │           ├── SocksProxyServer.java
│       │   │           ├── SourceMarker.java
│       │   │           ├── WriteFile.java
│       │   │           └── WriteJavaIoFile.java
│       │   └── kotlin/
│       │       └── okio/
│       │           └── samples/
│       │               ├── BitmapEncoder.kt
│       │               ├── ExploreCharsets.kt
│       │               ├── GoldenValue.kt
│       │               ├── Hashing.kt
│       │               ├── ReadJavaIoFileLineByLine.kt
│       │               ├── SocksProxyServer.kt
│       │               ├── TeeSink.kt
│       │               ├── WriteFile.kt
│       │               └── WriteJavaIoFile.kt
│       └── jvmTest/
│           └── java/
│               └── okio/
│                   └── samples/
│                       ├── ChannelsTest.kt
│                       └── SourceMarkerTest.kt
└── settings.gradle.kts

================================================
FILE CONTENTS
================================================

================================================
FILE: .buildscript/prepare_mkdocs.sh
================================================
#!/bin/bash

# The website is built using MkDocs with the Material theme.
# https://squidfunk.github.io/mkdocs-material/
# It requires Python to run.
# Install the packages with the following command:
# pip install mkdocs mkdocs-material

set -ex

# Generate the API docs
./gradlew dokkaHtml

# Copy in special files that GitHub wants in the project root.
cp CHANGELOG.md docs/changelog.md
cp CONTRIBUTING.md docs/contributing.md


================================================
FILE: .buildscript/restore_v1_docs.sh
================================================
#!/bin/bash

# Commit b3205fa199a19d6fbf13ee5c8e0c3d6d2b15b05f contains
# Javadoc for Okio 1.x. Those should be present on
# gh-pages and published along with the other website
# content, but if for some reason they have to be re-added
# to gh-pages - run this script locally.

set -ex

DIR=temp-clone

# Delete any existing temporary website clone
rm -rf $DIR

# Clone the current repo into temp folder
git clone . $DIR

# Move working directory into temp folder
cd $DIR

# Restore docs from 1.x
git checkout b3205fa199a19d6fbf13ee5c8e0c3d6d2b15b05f
mkdir -p ../site
mv ./1.x ../site/1.x

# Restore docs from 2.x
git checkout 9235ff8faca96082aa8784e789448b5f4893af69
mkdir -p ../site
mv ./2.x ../site/2.x

# Delete our temp folder
cd ..
rm -rf $DIR


================================================
FILE: .editorconfig
================================================
root = true

[*]
insert_final_newline=true
end_of_line=lf
charset=utf-8
indent_size=2
trim_trailing_whitespace=true

[*.{kt,kts}]
ij_kotlin_allow_trailing_comma=true
ij_kotlin_allow_trailing_comma_on_call_site=true
ij_kotlin_imports_layout=*


================================================
FILE: .gitattributes
================================================
* text=auto eol=lf

*.bat text eol=crlf
*.jar binary

================================================
FILE: .github/renovate.json5
================================================
{
  $schema: 'https://docs.renovatebot.com/renovate-schema.json',
  extends: [
    'config:recommended',
  ],
  ignorePresets: [
    // Ensure we get the latest version and are not pinned to old versions.
    'workarounds:javaLTSVersions',
  ],
  customManagers: [
    // Update .java-version file with the latest JDK version.
    {
      customType: 'regex',
      fileMatch: [
        '\\.java-version$',
      ],
      matchStrings: [
        '(?<currentValue>.*)\\n',
      ],
      datasourceTemplate: 'java-version',
      depNameTemplate: 'java',
      // Only write the major version.
      extractVersionTemplate: '^(?<version>\\d+)',
    },
  ]
}


================================================
FILE: .github/workflows/.java-version
================================================
25


================================================
FILE: .github/workflows/build.yml
================================================
name: build

on:
  pull_request: {}
  workflow_dispatch: {}
  push:
    branches:
      - 'master'
    tags-ignore:
      - '**'

env:
  GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx2g -Dorg.gradle.daemon=false -Dkotlin.incremental=false"

jobs:
  jvm:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        java-version:
          - 8
          - 11
          - 17
          - latest

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Validate Gradle Wrapper
        uses: gradle/actions/wrapper-validation@v5

      - uses: actions/setup-java@v5
        with:
          distribution: 'zulu'
          java-version-file: .github/workflows/.java-version

      - name: Test
        run: |
          ./gradlew -Dkjs=false -Dknative=false -Dkwasm=false -Dtest.java.version=${{ matrix.java-version }} build --stacktrace

  emulator:
    runs-on: ubuntu-latest
    steps:
      # https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
      - name: Enable KVM group perms
        run: |
          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
          sudo udevadm control --reload-rules
          sudo udevadm trigger --name-match=kvm
          ls /dev/kvm
      - uses: actions/checkout@v6
      - uses: actions/setup-java@v5
        with:
          distribution: 'zulu'
          java-version-file: .github/workflows/.java-version

      - uses: gradle/actions/setup-gradle@v5

      - uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: 24
          script: ./gradlew :okio-assetfilesystem:connectedCheck

  loom:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Validate Gradle Wrapper
        uses: gradle/actions/wrapper-validation@v5

      - uses: actions/setup-java@v5
        with:
          distribution: 'zulu'
          java-version-file: .github/workflows/.java-version

      - name: Test
        run: |
          ./gradlew -DloomEnabled=true build

  all-platforms:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        os: [ macos-14, ubuntu-latest, windows-latest ]

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Validate Gradle Wrapper
        uses: gradle/actions/wrapper-validation@v5

      - uses: actions/setup-java@v5
        with:
          distribution: 'zulu'
          java-version-file: .github/workflows/.java-version

      - name: Test
        if: matrix.os != 'windows-latest'
        run: |
          ./gradlew build

      - name: Test (No WASM)
        if: matrix.os == 'windows-latest'
        run: |
          ./gradlew build -Dkwasm=false

      - name: Save Test Reports
        if: failure()
        uses: actions/upload-artifact@v7
        with:
          name: test-reports
          path: '**/build/reports'

  publish:
    runs-on: macos-15
    if: github.repository == 'square/okio' && github.ref == 'refs/heads/master'
    needs: [jvm, all-platforms, emulator]

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - uses: actions/setup-java@v5
        with:
          distribution: 'zulu'
          java-version-file: .github/workflows/.java-version

      - name: Upload Artifacts
        run: |
          ./gradlew publish --stacktrace
        env:
          ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_CENTRAL_USERNAME }}
          ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }}
          ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SECRET_KEY }}
          ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SECRET_PASSPHRASE }}

  publish-website:
    runs-on: ubuntu-latest
    if: github.repository == 'square/okio' && github.ref == 'refs/heads/master'
    needs: [jvm, all-platforms, emulator]

    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - uses: actions/setup-java@v5
        with:
          distribution: 'zulu'
          java-version-file: .github/workflows/.java-version

      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: 3.14

      - name: Prepare docs
        run: .buildscript/prepare_mkdocs.sh

      - name: Build mkdocs
        run: |
          pip3 install mkdocs-material mkdocs-macros-plugin
          mkdocs build

      - name: Restore 1.x docs
        run: .buildscript/restore_v1_docs.sh

      - name: Deploy docs
        if: success()
        uses: JamesIves/github-pages-deploy-action@releases/v3
        with:
          GITHUB_TOKEN: ${{ secrets.GH_CLIPPY_TOKEN }}
          BRANCH: gh-pages
          FOLDER: site
          SINGLE_COMMIT: true


================================================
FILE: .github/workflows/release.yaml
================================================
name: release

on:
  push:
    tags:
      - '**'

env:
  GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false -Dkotlin.incremental=false"

jobs:
  publish:
    runs-on: macos-15

    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-java@v5
        with:
          distribution: 'zulu'
          java-version-file: .github/workflows/.java-version

      - run: ./gradlew publish
        env:
          ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_CENTRAL_USERNAME }}
          ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }}
          ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SECRET_KEY }}
          ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SECRET_PASSPHRASE }}


================================================
FILE: .gitignore
================================================
.classpath
.gradle
.kotlin
.project
.settings
eclipsebin

bin
gen
build
out
lib
reports

.idea
*.iml
*.ipr
*.iws
classes
local.properties

obj

.DS_Store

node_modules

# Special Mkdocs files
docs/3.x
docs/changelog.md
docs/contributing.md


================================================
FILE: BUG-BOUNTY.md
================================================
Serious about security
======================

Square recognizes the important contributions the security research community
can make. We therefore encourage reporting security issues with the code
contained in this repository.

If you believe you have discovered a security vulnerability, please follow the
guidelines at https://bugcrowd.com/engagements/blockopensource.



================================================
FILE: CHANGELOG.md
================================================
Change Log
==========

## Unreleased

 * None yet.

## Version 3.17.0

_2026-03-11_

 * New: Adjust down the Kotlin stdlib dependency to [Kotlin 2.1.21][kotlin_2_1_21]. Okio is built
   with an up-to-date Kotlin compiler (2.2.21), but depends on an older kotlin-stdlib. We're doing
   this so you can update Okio and Kotlin independently.

 * Fix: Return the correct timestamp in `FileMetadata.createdAtMillis` on Kotlin/Native on UNIX
   platforms. We were incorrectly using the POSIX `ctime` (_change_ time) instead of the
   `birthtime`. With this fix Okio now prefers `statx()` over `stat()` on native platforms. This
   API first appeared in Linux in 4.11 (2017) and Android in API 30 (2020).


## Version 3.16.4

_2025-11-17_

* Fix: Don't delay triggering timeouts. In 3.16.0 we introduced a regression that caused timeouts
  to fire later than they were supposed to.


## Version 3.16.3

_2025-11-14_

This release is the same as 3.16.2. We forgot to cherry-pick a commit before we released!


## Version 3.16.2

_2025-10-14_

 * Fix: `okio-assetfilesystem` APIs now correctly restored as visible to Kotlin.


## Version 3.16.1

_2025-10-09_

 * Fix: Don't crash when calling `Socket.shutdownOutput()` or `shutdownInput()` on an `SSLSocket` on
   Android API 21. This method throws an `UnsupportedOperationException`, so we now catch that and
   close the underlying stream instead.


## Version 3.16.0

_2025-07-29_

 * Fix: Change `Socket.asOkioSocket()` to resolve its source `InputStream` and `OutputStream`
   eagerly. This will throw a `SocketException` immediately if the socket isn’t connected.
   This behavior is consistent with our similar APIs, `Socket.source()` and `Socket.sink()`.

 * Fix: Optimize `AsyncTimeout` on systems with a very large number of active timeouts. This class
   originally kept active timeouts in a linked list; with this update the internal data structure is
   a binary heap. The old runtime was 𝑂(𝑛²) to activate 𝑛 timeouts; with this optimization the
   runtime is 𝑂(𝑛 log 𝑛).

 * Upgrade: [Kotlin 2.2.0][kotlin_2_2_0].


## Version 3.15.0

_2025-07-01_

 * Upgrade: [kotlinx-datetime 0.7.0-0.6.x-compat][datetime_0_7_0_compat]. The previous 3.14.0
   release, `FakeFileSystem` broke binary-compatibility for calls to `FakeFileSystem()`. This
   restores that compatibility.

 * Breaking: Change `FakeFileSystem.clock` from a JVM field to a property. This avoids a crash
   running Okio in a Gradle 8.x plugin. This change is not binary-compatible.


## Version 3.14.0

_2025-06-28_

 * Upgrade: [kotlinx-datetime 0.7.0][datetime_0_7_0]. This impacts the `okio-fakefilesystem`
   artifact only. This is a binary-incompatible backwards-incompatible change that cannot co-exist
   with previous releases of `okio-fakefilesystem`! If you observe a `NoSuchMethodError` calling
   `FakeFileSystem.init`, update the calling code to this release (or newer) and recompile. We don't
   like imposing backwards-incompatible changes like this on you and do so regretfully.


## Version 3.13.0

_2025-06-13_

 * New: `okio.Socket` interface. This is a first step towards low-level streaming networking support
   for Kotlin/Multiplatform. This release provides two JVM-only implementations: `asOkioSocket()`
   adapts a `java.net.Socket` to our new interface, and `inMemorySocketPair()` returns a pair of
   mutually-connected sockets. We also anticipate that this interface will be a useful abstraction
   for proxies and tunnels.
 * New: In-development snapshots are now published to the [Central Portal Snapshots repository].


## Version 3.12.0

_2025-05-27_

 * New: Support an optional end index when searching with `BufferedSource.indexOf()`.
 * Fix: Don't do unnecessary work in `BufferedSource.rangeEquals()`.
 * Upgrade: [Kotlin 2.1.21][kotlin_2_1_21].


## Version 3.11.0

_2025-04-09_

 * Fix: Clear the deflater's byte array reference
 * New: Faster implementation of `String.decodeHex()` on Kotlin/JS.
 * New: Declare `EXACTLY_ONCE` execution for blocks like `Closeable.use {}` and `FileSystem.read {}`.
 * Upgrade: [Kotlin 2.1.20][kotlin_2_1_20].


## Version 3.10.2

_2025-01-08_

 * Fix: `okio-nodefilesystem` artifact is no longer empty.


## Version 3.10.1

_2025-01-07_

 * New: `FileSystem.close()` may prevent future access and/or clean up associated resources depending on the backing implementation. `FakeFileSystem` will prevent future operations once closed.
 * `InputStream`s created from `BufferedSource.inputStream()` now have a more efficient version of `InputStream.transferTo()` which reduces memory copies.
 * `okio-nodefilesystem` is no longer publised as a JS project, but a Kotlin multiplatform project with only a JS target. ~This change should not affect consumers in any way, and is motivated by the Kotlin Gradle plugin deprecating the JS-only plugin.~ Please use 3.10.2 to ensure this change actually does not affect your builds.


## Version 3.10.0

_2025-01-06_

This version is equivalent to the subsequent 3.10.1, but it did not fully publish to Maven Central due to infrastructure problems.


## Version 3.9.1

_2024-09-12_

 * Fix: Support paths containing a single dot (".") in `Path.relativeTo`.
 * Fix: Do not read from the upstream source when a 0-byte read is requested.
 * Fix: Update kotlinx.datetime to 0.6.0 to correct a Gradle module metadata problem with 0.5.0.
   Note: this artifact is only used in 'okio-fakefilesystem' and 'okio-nodefilesystem' and not in the Okio core.


## Version 3.9.0

_2024-03-12_

 * New: `FileSystem.SYSTEM` can be used in source sets that target both Kotlin/Native and
   Kotlin/JVM. Previously, we had this symbol in each source set but it wasn't available to
   common source sets.
 * New: `COpaquePointer.readByteString(...)` creates a ByteString from a memory address.
 * New: Support `InflaterSource`, `DeflaterSink`, `GzipSink`, and `GzipSource` in Kotlin/Native.
 * New: Support openZip() on Kotlin/Native. One known bug in this implementation is that
   `FileMetadata.lastModifiedAtMillis()` is interpreted as UTC and not the host machine's time zone.
 * New: Prefer NTFS timestamps in ZIP file systems' metadata. This avoids the time zone problems
   of ZIP's built-in DOS timestamps, and the 2038 time bombs of ZIP's extended timestamps.
 * Fix: Don't leak file handles to opened JAR files open in `FileSystem.RESOURCES`.
 * Fix: Don't throw a `NullPointerException` if `Closeable.use { ... }` returns null.


## Version 3.8.0

_2024-02-09_

 * New: `TypedOptions` works like `Options`, but it returns a `T` rather than an index.
 * Fix: Don't leave sinks open when there's a race in `Pipe.fold()`.


## Version 3.7.0

_2023-12-16_

 * New: `Timeout.cancel()` prevents a timeout from firing.
 * Breaking: Drop the `watchosX86` Kotlin/Native target. From [the Kotlin blog][watchosX86],
   _‘This is an obsolete simulator for Intel Macs. Use the watchosX64 target instead.’_
 * New: Add the `watchosDeviceArm64` Kotlin/Native target.
 * New: `Timeout` APIs that accept `kotlin.time.Duration`.
 * Upgrade: [Kotlin 1.9.21][kotlin_1_9_21].


## Version 3.6.0

_2023-10-01_

 * Fix: Don't leak file handles when using `metadata` functions on `ZipFileSystem`. We had a bug
   where we were closing the `.zip` file, but not a stream inside of it. We would have prevented
   this bug if only we’d used `FakeFileSystem.checkNoOpenFiles()` in our tests!
 * Fix: Don't build an index of a class loader's resources in `ResourceFileSystem.read()`. This
   operation doesn't need this index, and building it is potentially expensive.
 * New: Experimentally support Linux on ARM64 for Kotlin/Native targets (`linuxArm64`). Note that
   we haven't yet added CI test coverage for this platform.
 * Upgrade: [Kotlin 1.9.10][kotlin_1_9_10].


## Version 1.17.6

_2023-10-01_

 * Fix: Don't crash decoding GZIP files when the optional extra data (`XLEN`) is 32 KiB or larger.


## Version 3.5.0

_2023-08-02_

 * New: Support the WebAssembly (WASM) platform. Okio's support for WASM is experimental, but
   improving, just like Kotlin's own support for WASM.
 * New: Adapt WebAssembly System Interface (WASI) API's as an Okio FileSystem using
   `WasiFileSystem`. This is in the new `okio-wasifilesystem` module. It requires the [preview1]
   WASI API. We’ll make backwards-incompatible upgrades to new WASI API versions as they become
   available.
 * Fix: Return relative paths in the NIO adapter FileSystem when required. `FileSystem.list()`
   had always returned absolute paths, even when the target directory was supplied as a relative
   path.
 * Fix: Don't crash when reading into an empty array using `FileHandle` on Kotlin/Native.
 * Upgrade: [Kotlin 1.9.0][kotlin_1_9_0].


## Version 3.4.0

_2023-07-07_

 * New: Adapt a Java NIO FileSystem (`java.nio.file.FileSystem`) as an Okio FileSystem using
   `fileSystem.asOkioFileSystem()`.
 * New: Adapt Android’s `AssetManager` as an Okio FileSystem using `AssetFileSystem`. This is in the
   new `okio-assetfilesystem` module. Android applications should prefer this over
   `FileSystem.RESOURCES` as it’s faster to load.
 * Fix: Don't crash decoding GZIP files when the optional extra data (`XLEN`) is 32 KiB or larger.
 * Fix: Resolve symlinks in `FakeFileSystem.canonicalize()`.
 * Fix: Report the correct `createdAtMillis` in `NodeJsFileSystem` file metadata. We were
   incorrectly using `ctimeMs`, where `c` means _changed_, not _created_.
 * Fix: `UnsafeCursor` is now `Closeable`.


## Version 3.3.0

_2023-01-07_

 * Fix: Don't leak resources when `use {}` is used with a non-local return. We introduced this
   performance and stability bug by not considering that non-local returns execute neither the
   `return` nor `catch` control flows.
 * Fix: Use a sealed interface for `BufferedSink` and `BufferedSource`. These were never intended
   for end-users to implement, and we're happy that Kotlin now allows us to express that in our API.
 * New: Change internal locks from `synchronized` to `ReentrantLock` and `Condition`. We expect this
   to improve help when using Okio with Java virtual threads ([Project Loom][loom]).
 * Upgrade: [Kotlin 1.8.0][kotlin_1_8_0].


## Version 3.2.0

_2022-06-26_

 * Fix: Configure the multiplatform artifact (`com.squareup.okio:okio:3.x.x`) to depend on the
   JVM artifact (`com.squareup.okio:okio-jvm:3.x.x`) for Maven builds. This should work-around an
   issue where Maven doesn't interpret Gradle metadata.
 * Fix: Change `CipherSource` and `CipherSink` to recover if the cipher doesn't support streaming.
   This should work around a crash with AES/GCM ciphers on Android.
 * New: Enable compatibility with non-hierarchical projects.


## Version 3.1.0

_2022-04-19_

 * Upgrade: [Kotlin 1.6.20][kotlin_1_6_20].
 * New: Support [Hierarchical project structure][hierarchical_projects]. If you're using Okio in a
   multiplatform project please upgrade your project to Kotlin 1.6.20 (or newer) to take advantage
   of this. With hierarchical projects it's easier to use properties like `FileSystem.SYSTEM` that
   are available on most Okio platforms but not all of them.
 * New: `ForwardingSource` is now available on all platforms.
 * New: The `watchosX64` platform is now supported.
 * Fix: Don't crash in `NSData.toByteString()' when the input is empty.
 * Fix: Support empty ZIP files in `FileSystem.openZip()`.
 * Fix: Throw in `canonicalize()` of ZIP file systems if the path doesn't exist.
 * Fix: Don't require ZIP files start with a local file header.
 * New: `okio.ProtocolException` is a new exception type for multiplatform users. (It is aliased to
   `java.net.ProtocolException` on JVM platforms).


## Version 3.0.0

_2021-10-28_

This is the first stable release of Okio 3.x. This release is strongly backwards-compatible with
Okio 2.x, and the new major version signifies new capabilities more than it does backwards
incompatibility.

Most users should be able to upgrade from 2.x by just changing the version. If you're using Okio
in a Kotlin Multiplatform project, you'll need to drop the `-multiplatform` suffix in your Gradle
dependencies.

 * New: Remove `@ExperimentalFileSystem`. This annotation is no longer necessary as the file system
   is no longer experimental!
 * New: Path no longer aggressively normalizes `..` segments. Use `Path.normalize()` to apply these
   based on the content of the path, or `FileSystem.canonicalize()` to do it honoring any symlinks
   on a particular file system.
 * New: Publish a [bill of materials (BOM)][bom] for Okio. Depend on this from Gradle or Maven to
   keep all of your Okio artifacts on the same version, even if they're declared via transitive
   dependencies. You can even omit versions when declaring other Okio dependencies.

   ```kotlin
   dependencies {
      api(platform("com.squareup.okio:okio-bom:3.0.0"))
      api("com.squareup.okio:okio")                // No version!
      api("com.squareup.okio:okio-fakefilesystem") // No version!
   }
   ```

 * New: `FileSystem.delete()` silently succeeds when deleting a file that doesn't exist. Use
   the new `mustExist` parameter to trigger an exception instead.
 * New: `FileSystem.createDirectories()` silently succeeds when creating a directory that already
   exists. Use the new `mustCreate` parameter to trigger an exception instead.
 * New: `FileSystem` offers Java-language overloads where appropriate. Previously functions that
   had default parameters were potentially awkward to invoke from Java.
 * New: `Timeout.intersectWith()` returns a value instead of `Unit`. This is a binary-incompatible
   change. We expect that this public API is very rarely used outside of Okio itself.
 * Fix: Change `BufferedSource.readDecimalLong()` to fail if the input value is just `-`. Previously
   Okio incorrectly returned `0` for this.


## Version 3.0.0-alpha.11

_2021-10-23_

 * Upgrade: [Kotlin 1.5.31][kotlin_1_5_31].
 * Upgrade: [kotlinx-datetime 0.3.0][datetime_0_3_0]. (This is a dependency of `okio-fakefilesystem`
   only.)
 * New: Support creating and accessing symlinks. We were reluctant to include symlinks in our API
   (to keep it small!) but decided that supporting them was essential to properly implement
   recursive traversal.
 * New: `FileMetadata.extras` can track metadata for custom `FileSystem` implementations.
 * New: Support Apple Silicon Kotlin/Native targets (`macosArm64`, `iosSimulatorArm64`,
   `tvosSimulatorArm64`, and `watchosSimulatorArm64`).
 * New: `FileSystem.listRecursively()` returns a `Sequence` that includes all of a directory's
   children, and all of their children recursively. The implementation does a lazy, depth-first
   traversal.
 * New: `Path.relativeTo()` computes how to get from one path to another.
 * New: `Path.root` and `Path.segments`. These APIs decompose a path into its component parts.
 * New: `FileSystem.listOrNull()` returns a directory's children, or null if the path doesn't
   reference a readable directory.
 * New: Option to fail if the file being updated doesn't already exist: `mustExist`. Use this to
   avoid creating a new file when your intention is to update an existing file.
 * New: Option to fail if a file being created already exists: `mustCreate`. Use this to avoid
   updating an existing file when your intention is to create a new file.
 * Fix: Restore support for Kotlin/JS on browser platforms. We were relying on NodeJS-only features
   to fetch the local directory separator (`/` or `\`) and temporary directory.
 * Fix: Don't ignore the caller's specified write offset running Okio on Kotlin/Native on Linux.
   (`FileHandle.write()` was broken and always appended to the end of the file.)


## Version 3.0.0-alpha.10

_2021-09-09_

This release drops the `-multiplatform` suffix on Kotlin Multiplatform artifacts. All artifacts now
share the same name (like `com.squareup.okio:okio:3.0.0-alpha.10`) for both Kotlin/JVM and Kotlin
Multiplatform.

 * Fix: Don't crash in `ResourceFileSystem` when classpath `.jar` files have special characters in
   their paths.


## Version 3.0.0-alpha.9

_2021-08-01_

 * New: `ByteString.copyInto()` saves an allocation when extracting data from a `ByteString`.
 * Fix: Create `FileHandle.protectedSize()` to match other abstract functions.
 * Fix: Open files in binary mode on Windows. Without this, files that contain `0x1a` will be
   truncated prematurely.


## Version 3.0.0-alpha.8

_2021-07-13_

 * Fix: Don't crash on duplicate entries in a .zip file.
 * Fix: Change `FileSystem.RESOURCES` to initialize itself lazily.


## Version 3.0.0-alpha.7

_2021-07-12_

 * Fix: Change `ResourceFileSystem` to load roots eagerly. We had a bug where `list()` on the root
   returned an empty list even if resources were present.
 * New: `FileHandle.reposition()` can seek on a source or sink returned by that `FileHandle`.
 * New: Move the system resources instance to `FileSystem.RESOURCES`.
 * Upgrade: [Kotlin 1.5.20][kotlin_1_5_20].


## Version 3.0.0-alpha.6

_2021-06-01_

 * New: `FileHandle` supports random access reads, writes, and resizes on files. Create an instance
   with `FileSystem.openReadOnly()` or `FileSystem.openReadWrite()`.
 * New: Remove `Cursor` which is obsoleted by `FileHandle`. (`UnsafeCursor` is still around!)
 * New: Add support for the new intermediate representation (IR) artifacts in Kotlin/JS. We still
   support the legacy artifact format.
 * New: Support tvOS (tvosArm64, tvosX64) in multiplatform.
 * New: Change `ResourceFileSystem` to omit `.class` files when indexing `.zip` files. We expect
   this to lower the memory footprint of `ResourceFileSystem`.
 * Fix: Don't crash on background thread access in Kotlin/Native. We had to apply `@SharedImmutable`
   and run our test suite on a background thread.


## Version 3.0.0-alpha.5

_2021-04-27_

 * New: Promote the `ZipFileSystem` and `ResourceFileSystem` to the main Okio module. These are
   currently JVM-only. The `okio-zipfilesystem` module is no longer published.


## Version 3.0.0-alpha.4

_2021-04-14_

 * Fix: Rename internal classes to avoid name collisions. We were seeing problems due to having
   multiple files named `-Platform.kt`.


## Version 3.0.0-alpha.3

_2021-04-06_

 * New: Move `NodeJsFileSystem` into its own module. Having it built-in prevented Okio from working
   in a browser where there's no synchronous file system API. This is in the `okio-nodefilesystem`
   artifact.


## Version 3.0.0-alpha.2

_2021-03-24_

 * New: Require Java 8+ for Okio 3.x.
 * New: `Cursor` supports random access reads on a `Source`.
 * New: `FileSystem.openZip(path)` returns a file system backed by a `.zip` file. This is in the
   `okio-zipfilesystem` artifact.


## Version 3.0.0-alpha.1

_2021-01-07_

* New: Experimental file system API. The `Path`, `FileMetadata`, `FileSystem` and
  `ForwardingFileSystem` types are subject to API changes in a future release.
* New: Experimental `okio-fakefilesystem` artifact.


## Version 2.10.0

_2021-01-07_

* New: Support Windows (mingwX64) in multiplatform.
* New: Support watchOS (watchosArm32, watchosArm64, watchosX86) in multiplatform.
* New: Support `HashingSource`, `HashingSink`, buffer hash functions, and `UnsafeCursor` on non-JVM
  platforms. Previously these were all JVM-only.
* New: Implement `Closeable` on `Sink` and `Source` on non-JVM platforms. Okio now includes a
  multiplatform `okio.Closeable` interface and corresponding `use {}` extension. Closing resources
  when you're done with them shouldn't be JVM-only!
* New: `Sink.hashingSink` and `Source.hashingSource` functions that accept
  `java.security.MessageDigest` and `javax.crypto.Mac` instances. Use these when your hash function
  isn't built-in.
* Fix: Don't crash with a `ShortBufferException` in `CipherSink` and `CipherSource` on Android.
  (Android may throw a `ShortBufferException` even if the buffer is not too short. We now
  avoid this problem!)
* Upgrade: [Kotlin 1.4.20][kotlin_1_4_20].


## Version 2.9.0

_2020-10-04_

 * Fix: Don't corrupt the `Buffer` when writing a slice of a segmented `ByteString`. We had a severe
   bug where `ByteString` instances created with `snapshot()` and `readByteString()` incorrectly
   adjusted the buffer's size by their full length, not the length of the slice. This would have
   caused buffer reads to crash! We do not believe data was silently corrupted.
 * New: `CipherSink` and `CipherSource`. Use these with `javax.crypto.Cipher` to encrypt and decrypt
   streams of data. This is a low-level encryption API; most applications should use higher-level
   APIs like TLS when available.
 * New: Promote hash functions `md5`, `sha1()`, `sha512()`, and `sha256()` to common Kotlin. These
   are currently only available on `ByteString`, multiplatform support for `HashingSource`,
   `HashingSink`, and `Buffer` should come in a follow-up release. We wrote and optimized our own
   implementations of these hash functions in Kotlin. On JVM and Android platforms Okio still uses
   the platform's built-in hash functions.
 * New: Support OSGi metadata.
 * Upgrade: [Kotlin 1.4.10][kotlin_1_4_10].


## Version 2.8.0

_2020-08-17_

 * New: Upgrade to Kotlin 1.4.0.


## Version 2.7.0

_2020-07-07_

 * New: `Pipe.cancel()` causes in-progress and future reads and writes on the pipe to immediately
   fail with an `IOException`. The streams may still be canceled normally.

 * New: Enlarge Okio's internal segment pool from a fixed 64 KiB total to 64 KiB per processor. For
   example, on an Intel i9 8-core/16-thread machine the segment pool now uses up to 1 MiB of memory.

 * New: Migrate from `synchronized` to lock-free when accessing the segment pool. Combined with the
   change above we saw throughput increase 3x on a synthetic benchmark designed to create
   contention.


## Version 2.6.0

_2020-04-22_

 * New: `InflaterSource.readOrInflate()` is like `InflaterSource.read()`, except it will return 0 if
   consuming deflated bytes from the underlying stream did not produce new inflated bytes.


## Version 2.5.0

_2020-03-20_

 * New: Upgrade to Kotlin 1.3.70.


## Version 2.4.3

_2019-12-20_

 * New: Upgrade to Kotlin 1.3.61.


## Version 2.4.2

_2019-12-11_

 * Fix: Don't crash when an `InputStream` source is exhausted exactly at a buffer segment boundary.
   We had a bug where a sequence of reads could violate a buffer's invariants, and this could result
   in a crash when subsequent reads encountered an unexpected empty segment.


## Version 1.17.5

_2019-12-11_

 * Fix: Don't crash when an `InputStream` source is exhausted exactly at a buffer segment boundary.
   We had a bug where a sequence of reads could violate a buffer's invariants, and this could result
   in a crash when subsequent reads encountered an unexpected empty segment.


## Version 2.4.1

_2019-10-04_

 * Fix: Don't cache hash code and UTF-8 string in `ByteString` on Kotlin/Native which prevented freezing.

## Version 2.4.0

_2019-08-26_

 * New: Upgrade to Kotlin 1.3.50.


## Version 2.3.0

_2019-07-29_

**This release changes our build from Kotlin-JVM to Kotlin-multiplatform (which includes JVM).**
Both native and JavaScript platforms are unstable preview releases and subject to
backwards-incompatible changes in forthcoming releases.

To try Okio in a multiplatform project use this Maven coordinate:

```kotlin
api('com.squareup.okio:okio-multiplatform:2.3.0')
```

You’ll also need to [enable Gradle metadata][gradle_metadata] in your project's settings. The
artifact name for JVM projects has not changed.

 * New: Upgrade to Kotlin 1.3.40.
 * Fix: Use Gradle `api` instead of `implementation` for the kotlin-stdlib dependency.
 * Fix: Don't block unless strictly necessary in `BufferedSource.peek()`.

## Version 1.17.4

_2019-04-29_

 * Fix: Don't block unless strictly necessary in `BufferedSource.peek()`.


## Version 2.2.2

_2019-01-28_

 * Fix: Make `Pipe.fold()` close the underlying sink when necessary.


## Version 1.17.3

_2019-01-28_

 * Fix: Make `Pipe.fold()` close the underlying sink when necessary.


## Version 1.17.2

_2019-01-17_

 * Fix: Make `Pipe.fold()` flush the underlying sink.


## Version 2.2.1

_2019-01-17_

 * Fix: Make `Pipe.fold()` flush the underlying sink.


## Version 2.2.0

_2019-01-16_

 * New: `Throttler` limits sources and sinks to a maximum desired throughput. Multiple sources and
   sinks can be attached to the same throttler and their combined throughput will not exceed the
   desired throughput. Multiple throttlers can also be used on the same source or sink and they will
   all be honored.

 * New: `Pipe.fold()` replaces the actively-readable `Source` with a passively-writable `Sink`.
   This can be used to forward one sink to a target that is initially undetermined.

 * New: Optimize performance of ByteStrings created with `Buffer.snapshot()`.


## Version 1.17.1

_2019-01-16_

 * Fix: Make the newly-backported `Pipe.fold()` public.


## Version 1.17.0

_2019-01-16_

 * New: Backport `Pipe.fold()` to Okio 1.x.


## Version 1.16.0

_2018-10-08_

 * New: Backport `BufferedSource.peek()` and `BufferedSource.getBuffer()` to Okio 1.x.
 * Fix: Enforce timeouts when closing `AsyncTimeout` sources.


## Version 2.1.0

_2018-09-22_

 * New: `BufferedSource.peek()` returns another `BufferedSource` that reads ahead on the current
   source. Use this to process the same data multiple times.

 * New: Deprecate `BufferedSource.buffer()`, replacing it with either `BufferedSource.getBuffer()`
   (in Java) or `BufferedSource.buffer` (in Kotlin). We have done likewise for `BufferedSink`.
   When we introduced the new extension method `Source.buffer()` in Okio 2.0 we inadvertently
   collided with an existing method. This fixes that.

 * New: Improve performance of `Buffer.writeUtf8()`. This comes alongside initial implementation of
   UTF-8 encoding and decoding in JavaScript which [uses XOR masks][xor_utf8] for great performance.


## Version 2.0.0

_2018-08-27_

This release commits to a stable 2.0 API. Read the 2.0.0-RC1 changes for advice on upgrading from
1.x to 2.x.

We've also added APIs to ease migration for Kotlin users. They use Kotlin's `@Deprecated` annotation
to help you change call sites from the 1.x style to the 2.x style.


## Version 2.0.0-RC1

_2018-07-26_

Okio 2 is a major release that upgrades the library's implementation language from Java to Kotlin.

Okio 2.x is **binary-compatible** with Okio 1.x and does not change any behavior. Classes and .jar
files compiled against 1.x can be used with 2.x without recompiling.

Okio 2.x is **.java source compatible** with Okio 1.x in all but one corner case. In Okio 1.x
`Buffer` would throw an unchecked `IllegalStateException` when attempting to read more bytes than
available. Okio 2.x now throws a checked `EOFException` in this case. This is now consistent with
the behavior of its `BufferedSource` interface. Java callers that don't already catch `IOException`
will now need to.

Okio 2.x is **.kt source-incompatible** with Okio 1.x. This release adopts Kotlin idioms where they
are available.

| Java                                     |  Kotlin                              | Idiom              |
| :--------------------------------------- |  :---------------------------------- | :----------------- |
| Buffer.getByte()                         |  operator fun Buffer.get()           | operator function  |
| Buffer.size()                            |  val Buffer.size                     | val                |
| ByteString.decodeBase64(String)          |  fun String.decodeBase64()           | extension function |
| ByteString.decodeHex(String)             |  fun String.decodeHex()              | extension function |
| ByteString.encodeString(String, Charset) |  fun String.encode(Charset)          | extension function |
| ByteString.encodeUtf8(String)            |  fun String.encodeUtf8()             | extension function |
| ByteString.getByte()                     |  operator fun ByteString.get()       | operator function  |
| ByteString.of(ByteBuffer)                |  fun ByteBuffer.toByteString()       | extension function |
| ByteString.of(byte[], int, int)          |  fun ByteArray.toByteString()        | extension function |
| ByteString.read(InputStream, int)        |  fun InputStream.readByteString(Int) | extension function |
| ByteString.size()                        |  val ByteString.size                 | val                |
| DeflaterSink(Sink)                       |  fun Sink.deflater()                 | extension function |
| ForwardingSink.delegate()                |  val ForwardingSink.delegate         | val                |
| ForwardingSource.delegate()              |  val ForwardingSource.delegate       | val                |
| GzipSink(Sink, Deflater)                 |  fun Sink.gzip()                     | extension function |
| GzipSink.deflater()                      |  val GzipSink.deflater               | val                |
| GzipSource(Source)                       |  fun Source.gzip()                   | extension function |
| HashingSink.hash()                       |  val HashingSink.hash                | val                |
| HashingSource.hash()                     |  val HashingSource.hash              | val                |
| InflaterSink(Source)                     |  fun Source.inflater()               | extension function |
| Okio.appendingSink(File)                 |  fun File.appendingSink()            | extension function |
| Okio.blackhole()                         |  fun blackholeSink()                 | top level function |
| Okio.buffer(Sink)                        |  fun Sink.buffer()                   | extension function |
| Okio.buffer(Source)                      |  fun Source.buffer()                 | extension function |
| Okio.sink(File)                          |  fun File.sink()                     | extension function |
| Okio.sink(OutputStream)                  |  fun OutputStream.sink()             | extension function |
| Okio.sink(Path)                          |  fun Path.sink()                     | extension function |
| Okio.sink(Socket)                        |  fun Socket.sink()                   | extension function |
| Okio.source(File)                        |  fun File.source()                   | extension function |
| Okio.source(InputStream)                 |  fun InputStream.source()            | extension function |
| Okio.source(Path)                        |  fun Path.source()                   | extension function |
| Okio.source(Socket)                      |  fun Socket.source()                 | extension function |
| Pipe.sink()                              |  val Pipe.sink                       | val                |
| Pipe.source()                            |  val Pipe.source                     | val                |
| Utf8.size(String)                        |  fun String.utf8Size()               | extension function |

Okio 2.x has **similar performance** to Okio 1.x. We benchmarked both versions to find potential
performance regressions. We found one regression and fixed it: we were using `==` instead of `===`.

Other changes in this release:

 * New: Add a dependency on kotlin-stdlib. Okio's transitive dependencies grow from none in 1.x to
   three in 2.x. These are kotlin-stdlib (939 KiB), kotlin-stdlib-common (104 KiB), and JetBrains'
   annotations (17 KiB).

 * New: Change Okio to build with Gradle instead of Maven.


## Version 1.15.0

_2018-07-18_

 * New: Trie-based `Buffer.select()`. This improves performance when selecting
   among large lists of options.
 * Fix: Retain interrupted state when throwing `InterruptedIOException`.


## Version 1.14.0

_2018-02-11_

 * New: `Buffer.UnsafeCursor` provides direct access to Okio internals. This API
   is like Okio's version of Java reflection: it's a very powerful API that can
   be used for great things and dangerous things alike. The documentation is
   extensive and anyone using it should review it carefully before proceeding!
 * New: Change `BufferedSource` to implement `java.nio.ReadableByteChannel` and
   `BufferedSink` to implement `java.nio.WritableByteChannel`. Now it's a little
   easier to interop between Okio and NIO.
 * New: Automatic module name of `okio` for use with the Java Platform Module
   System.
 * New: Optimize `Buffer.getByte()` to search backwards when doing so will be
   more efficient.
 * Fix: Honor the requested byte count in `InflaterSource`. Previously this
   class could return more bytes than requested.
 * Fix: Improve a performance bug in `AsyncTimeout.sink().write()`.


## Version 1.13.0

_2017-05-12_

 * **Okio now uses `@Nullable` to annotate all possibly-null values.** We've
   added a compile-time dependency on the JSR 305 annotations. This is a
   [provided][maven_provided] dependency and does not need to be included in
   your build configuration, `.jar` file, or `.apk`. We use
   `@ParametersAreNonnullByDefault` and all parameters and return types are
   never null unless explicitly annotated `@Nullable`.

 * **Warning: this release is source-incompatible for Kotlin users.**
   Nullability was previously ambiguous and lenient but now the compiler will
   enforce strict null checks.


## Version 1.12.0

_2017-04-11_

 * **Fix: Change Pipe's sink.flush() to not block.** Previously closing a pipe's
   sink would block until the source had been exhausted. In practice this
   blocked the caller for no benefit.
 * **Fix: Change `writeUtf8CodePoint()` to emit `?` for partial surrogates.**
   The previous behavior was inconsistent: given a malformed string with a
   partial surrogate, `writeUtf8()` emitted `?` but `writeUtf8CodePoint()` threw
   an `IllegalArgumentException`. Most applications will never encounter partial
   surrogates, but for those that do this behavior was unexpected.
 * New: Allow length of `readUtf8LineStrict()` to be limited.
 * New: `Utf8.size()` method to get the number of bytes required to encode a
   string as UTF-8. This may be useful for length-prefixed encodings.
 * New: SHA-512 hash and HMAC APIs.


## Version 1.11.0

_2016-10-11_

 * **Fix: The four-argument overload of `Buffer.writeString()` had a major bug
   where it didn't respect offsets if the specified charset was UTF-8.** This
   was because our short-circuit optimization omitted necessary offset
   parameters.
 * New: HMAC support in `HashingSource`, `HashingSink`, `ByteString`, and
   `Buffer`. This makes it easy to create a keyed-hash message authentication
   code (HMAC) wherever your data is. Unlike the other hashes, HMAC uses a
   `ByteString` secret key for authentication.
 * New: `ByteString.of(ByteBuffer)` makes it easier to mix NIO with Okio.


## Version 1.10.0

_2016-08-28_

 * Fix: Support reading files larger than 2 GiB with `GzipSource`. Previously
   attempting to decompress such files would fail due to an overflow when
   validating the total length.
 * Fix: Exit the watchdog thread after being idle for 60 seconds. This should
   make it possible for class unloaders to fully unload Okio.
 * New: `Okio.blackhole()` returns a sink where all bytes written are discarded.
   This is Okio's equivalent of `/dev/null`.
 * New: Encode a string with any charset using `ByteString.encodeString()` and
   decode strings in any charset using `ByteString.string()`. Most applications
   should prefer `ByteString.encodeUtf8()` and `ByteString.utf8()` unless it's
   necessary to support a legacy charset.
 * New: `GzipSink.deflater()` makes it possible to configure the compression
   level.


## Version 1.9.0

_2016-07-01_

 * New: `Pipe` makes it easy to connect a producer thread to a consumer thread.
   Reads block until data is available to read. Writes block if the pipe's is
   full. Both sources and sinks support timeouts.
 * New: `BufferedSource.rangeEquals()` makes it easy to compare a range in a
   stream to an expected value. This does the right thing: it blocks to load
   the data required return a definitive result. But it won't block
   unnecessarily.
 * New: `Timeout.waitUntilNotified()` makes it possible to use nice timeout
   abstractions on Java's built-in wait/notify primitives.
 * Fix: Don't return incorrect results when `HashingSource` does large reads.
   There was a bug where it wasn't traversing through the segments of the buffer
   being hashed. This means that `HashingSource` was returning incorrect answers
   for any writes that spanned multiple segment boundaries.

## Version 1.8.0

_2016-05-02_

 * New: `BufferedSource.select(Options)` API for reading one of a set of
   expected values.
 * New: Make `ByteString.toString()` and `Buffer.toString()` friendlier.
   These methods return text if the byte string is valid UTF-8.
 * New: APIs to match byte strings: `indexOf()`, `startsWith()`, and
   `endsWith()`.

## Version 1.7.0

_2016-04-10_

 * New: Change the segment size to 8 KiB. This has been reported to dramatically
   improve performance in some applications.
 * New: `md5()`, `sha1()`, and `sha256()` methods on `Buffer`. Also add a
   `sha1()` method on `ByteString` for symmetry.
 * New: `HashingSource` and `HashingSink`. These classes are Okio’s equivalent
   to the JDK’s `DigestInputStream` and `DigestOutputStream`. They offer
   convenient `md5()`, `sha1()`, and `sha256()` factory methods to avoid an
   impossible `NoSuchAlgorithmException`.
 * New: `ByteString.asByteBuffer()`.
 * Fix: Limit snapshot byte strings to requested size.
 * Fix: Change write timeouts to have a maximum write size. Previously large
   writes could easly suffer timeouts because the entire write was subject to a
   single timeout.
 * Fix: Recover from EBADF failures, which could be triggered by asynchronously
   closing a stream on older versions of Android.
 * Fix: Don't share segments if doing so only saves a small copy. This should
   improve performance for all applications.
 * Fix: Optimize `BufferedSource.indexOfElement()` and `indexOf(ByteString)`.
   Previously this method had a bug that caused it to be very slow on large
   buffers.

## Version 1.6.0

_2015-08-25_

 * New: `BufferedSource.indexOf(ByteString)` searches a source for the next
   occurrence of a byte string.
 * Fix: Recover from unexpected `AssertionError` thrown on Android 4.2.2 and
   earlier when asynchronously closing a socket.

## Version 1.5.0

_2015-06-19_

 * Sockets streams now throw `SocketTimeoutException`. This builds on new
   extension point in `AsyncTimeout` to customize the exception when a timeout
   occurs.
 * New: `ByteString` now implements `Comparable`. The comparison sorts bytes as
   unsigned: {@code ff} sorts after {@code 00}.

## Version 1.4.0

_2015-05-16_

 * **Timeout exception changed.** Previously `Timeout.throwIfReached()` would
   throw `InterruptedIOException` on thread interruption, and `IOException` if
   the deadline was reached. Now it throws `InterruptedIOException` in both
   cases.
 * Fix: throw `EOFException` when attempting to read digits from an empty
   source. Previously this would crash with an unchecked exception.
 * New: APIs to read and write UTF-8 code points without allocating strings.
 * New: `BufferedSink` can now write substrings directly, potentially saving an
   allocation for some callers.
 * New: `ForwardingTimeout` class.

## Version 1.3.0

_2015-03-16_

 * New: Read and write signed decimal and unsigned hexadecimal values in
   `BufferedSource` and `BufferedSink`. Unlike the alternatives, these methods
   don’t do any memory allocations!
 * New: Segment sharing. This improves the runtime of operations like
   `Buffer.clone()` and `Buffer.copyTo()` by sharing underlying segments between
   buffers.
 * New: `Buffer.snapshot()` returns an immutable snapshot of a buffer as a
   `ByteString`. This builds on segment sharing so that snapshots are shallow,
   immutable copies.
 * New: `ByteString.rangeEquals()`.
 * New: `ByteString.md5()` and `ByteString.sha256()`.
 * New: `ByteString.base64Url()` returns URL-safe Base64. The existing
   decoding method has been extended to support URL-safe Base64 input.
 * New: `ByteString.substring()` returns a prefix, infix, or suffix.
 * New: `Sink` now implements `java.io.Flushable`.
 * Fix: `Buffer.write(Source, long)` now always writes fully. The previous
   behavior would return as soon as any data had been written; this was
   inconsistent with all other _write()_ methods in the API.
 * Fix: don't leak empty segments in DeflaterSink and InflaterSource. (This was
   unlikely to cause problems in practice.)

## Version 1.2.0

_2014-12-30_

 * Fix: `Okio.buffer()` _always_ buffers for better predictability.
 * Fix: Provide context when `readUtf8LineStrict()` throws.
 * Fix: Buffers do not call through the `Source` on zero-byte writes.

## Version 1.1.0

_2014-12-11_

 * Do UTF-8 encoding natively for a performance increase, particularly on Android.
 * New APIs: `BufferedSink.emit()`, `BufferedSource.request()` and `BufferedSink.indexOfElement()`.
 * Fixed a performance bug in `Buffer.indexOf()`

## Version 1.0.1

_2014-08-08_

 * Added `read(byte[])`, `read(byte[], offset, byteCount)`,  and
   `void readFully(byte[])` to `BufferedSource`.
 * Refined declared checked exceptions on `Buffer` methods.


## Version 1.0.0

_2014-05-23_

 * Bumped release version. No other changes!

## Version 0.9.0

_2014-05-03_

 * Use 0 as a sentinel for no timeout.
 * Make AsyncTimeout public.
 * Remove checked exception from Buffer.readByteArray.

## Version 0.8.0

_2014-04-24_

 * Eagerly verify preconditions on public APIs.
 * Quick return on Buffer instance equivalence.
 * Add delegate types for Sink and Source.
 * Small changes to the way deadlines are managed.
 * Add append variant of Okio.sink for File.
 * Methods to exhaust BufferedSource to byte[] and ByteString.

## Version 0.7.0

_2014-04-18_

 * Don't use getters in timeout.
 * Use the watchdog to interrupt sockets that have reached deadlines.
 * Add java.io and java.nio file source/sink helpers.

## Version 0.6.1

_2014-04-17_

 * Methods to read a buffered source fully in UTF-8 or supplied charset.
 * API to read a byte[] directly.
 * New methods to move all data from a source to a sink.
 * Fix a bug on input stream exhaustion.

## Version 0.6.0

_2014-04-15_

 * Make ByteString serializable.
 * New API: `ByteString.of(byte[] data, int offset, int byteCount)`
 * New API: stream-based copy, write, and read helpers.

## Version 0.5.0

_2014-04-08_

 * Initial public release.
 * Imported from OkHttp.


[Central Portal Snapshots repository]: https://central.sonatype.org/publish/publish-portal-snapshots/
[bom]: https://docs.gradle.org/6.2/userguide/platforms.html#sub:bom_import
[datetime_0_3_0]: https://github.com/Kotlin/kotlinx-datetime/releases/tag/v0.3.0
[datetime_0_7_0]: https://github.com/Kotlin/kotlinx-datetime/releases/tag/v0.7.0
[datetime_0_7_0_compat]: https://github.com/Kotlin/kotlinx-datetime?tab=readme-ov-file#deprecation-of-instant
[gradle_metadata]: https://blog.gradle.org/gradle-metadata-1.0
[hierarchical_projects]: https://kotlinlang.org/docs/multiplatform-hierarchy.html
[kotlin_1_4_10]: https://github.com/JetBrains/kotlin/releases/tag/v1.4.10
[kotlin_1_4_20]: https://github.com/JetBrains/kotlin/releases/tag/v1.4.20
[kotlin_1_5_20]: https://github.com/JetBrains/kotlin/releases/tag/v1.5.20
[kotlin_1_5_31]: https://github.com/JetBrains/kotlin/releases/tag/v1.5.31
[kotlin_1_6_20]: https://blog.jetbrains.com/kotlin/2022/04/kotlin-1-6-20-released/
[kotlin_1_8_0]: https://kotlinlang.org/docs/whatsnew18.html
[kotlin_1_9_0]: https://kotlinlang.org/docs/whatsnew19.html
[kotlin_1_9_10]: https://github.com/JetBrains/kotlin/releases/tag/v1.9.10
[kotlin_1_9_21]: https://github.com/JetBrains/kotlin/releases/tag/v1.9.21
[kotlin_2_1_20]: https://github.com/JetBrains/kotlin/releases/tag/v2.1.20
[kotlin_2_1_21]: https://github.com/JetBrains/kotlin/releases/tag/v2.1.21
[kotlin_2_2_0]: https://github.com/JetBrains/kotlin/releases/tag/v2.2.0
[loom]: https://wiki.openjdk.org/display/loom/Getting+started
[maven_provided]: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
[preview1]: https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md
[watchosX86]: https://blog.jetbrains.com/kotlin/2023/02/update-regarding-kotlin-native-targets/
[xor_utf8]: https://github.com/square/okio/blob/bbb29c459e5ccf0f286e0b17ccdcacd7ac4bc2a9/okio/src/main/kotlin/okio/Utf8.kt#L302


================================================
FILE: CONTRIBUTING.md
================================================
Contributing
============

Keeping the project small and stable limits our ability to accept new contributors. We are not
seeking new committers at this time, but some small contributions are welcome.

If you've found a security problem, please follow our [bug bounty][security] program.

If you've found a bug, please contribute a failing test case so we can study and fix it.

Before code can be accepted all contributors must complete our
[Individual Contributor License Agreement (CLA)][cla].


Code Contributions
------------------

Get working code on a personal branch with tests passing before you submit a PR:

```
./gradlew clean check
```

Please make every effort to follow existing conventions and style in order to keep the code as
readable as possible.

Contribute code changes through GitHub by forking the repository and sending a pull request. We
squash all pull requests on merge.


Committer's Guides
------------------

 * [Releasing][releasing]

 [cla]: https://spreadsheets.google.com/spreadsheet/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1
 [releasing]: http://square.github.io/okio/releasing/
 [security]: http://square.github.io/okio/security/


================================================
FILE: LICENSE.txt
================================================

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: README.md
================================================
Okio
====

See the [project website][okio] for documentation and APIs.

Okio is a library that complements `java.io` and `java.nio` to make it much
easier to access, store, and process your data. It started as a component of
[OkHttp][1], the capable HTTP client included in Android. It's well-exercised
and ready to solve new problems.

License
--------

    Copyright 2013 Square, Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
    
 [1]: https://github.com/square/okhttp
 [okio]: https://square.github.io/okio/


================================================
FILE: android-test/README.md
================================================
Android Test
============

This module runs Okio's test suite on a connected Android emulator or device. It requires the same
set-up as [OkHttp's android-test module][okhttp_android_test].

In brief, configure the Android SDK and PATH:

```
export ANDROID_SDK_ROOT=/Users/$USER/Library/Android/sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin:$ANDROID_SDK_ROOT/platform-tools
```

Use `logcat` to stream test logs:

```
adb logcat '*:E' TestRunner:D TaskRunner:D GnssHAL_GnssInterface:F DeviceStateChecker:F memtrack:F
```

Then run the tests:

```
./gradlew :android-test:connectedAndroidTest
```

Or just a single test:

```
./gradlew :android-test:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=okio.SystemFileSystemTest
```


### Watch Out For Crashing Failures

Some of Okio's tests can cause the test process to crash. The test will be reported as a failure
with a message like this:

> Test failed to run to completion. Reason: 'Instrumentation run failed due to 'Process crashed.''.
> Check device logcat for details

When this happens, it's possible that tests are missing from the test run! One workaround is to
exclude the crashing test and re-run the rest. You can confirm that the test run completed normally
if a `run finished` line is printed in the logcat logs:

```
01-01 00:00:00.000 12345 23456 I TestRunner: run finished: 2976 tests, 0 failed, 3 ignored
```


[okhttp_android_test]: https://github.com/square/okhttp/tree/master/android-test


================================================
FILE: android-test/build.gradle.kts
================================================
import com.android.build.gradle.internal.lint.AndroidLintAnalysisTask

plugins {
  id("com.android.library")
}

buildscript {
  repositories {
    mavenCentral()
    gradlePluginPortal()
    google()
  }
}

val isIDE = properties.containsKey("android.injected.invoked.from.ide") ||
  (System.getenv("XPC_SERVICE_NAME") ?: "").contains("intellij") ||
  System.getenv("IDEA_INITIAL_DIRECTORY") != null

android {
  namespace = "com.squareup.okio"

  compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
    isCoreLibraryDesugaringEnabled = true
  }

  compileSdk = 33

  defaultConfig {
    minSdk = 15

    testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

    // AndroidJUnitRunner wasn't finding tests in multidex artifacts when running on Android 4.0.3.
    // Work around by adding all Okio classes to the keep list. That way they'll be in the main
    // .dx file where TestRequestBuilder will find them.
    multiDexEnabled = true
    multiDexKeepProguard = file("multidex-config.pro")
  }

  testOptions {
    targetSdk = 33
  }


  if (!isIDE) {
    sourceSets {
      named("androidTest") {
        java.srcDirs(
          project.file("../okio-fakefilesystem/src/commonMain/kotlin"),
          project.file("../okio/src/commonMain/kotlin"),
          project.file("../okio/src/commonTest/java"),
          project.file("../okio/src/commonTest/kotlin"),
          project.file("../okio/src/hashFunctions/kotlin"),
          project.file("../okio/src/jvmMain/kotlin"),
          project.file("../okio/src/jvmTest/java"),
          project.file("../okio/src/jvmTest/kotlin")
        )
      }
    }
  }
}

kotlin {
  compilerOptions {
    freeCompilerArgs.add("-Xmulti-platform")
  }
}

// https://issuetracker.google.com/issues/325146674
tasks.withType<AndroidLintAnalysisTask> {
  onlyIf { false }
}

dependencies {
  coreLibraryDesugaring(libs.android.desugar.jdk.libs)
  androidTestImplementation(libs.androidx.test.ext.junit)
  androidTestImplementation(libs.androidx.test.runner)
  androidTestImplementation(libs.kotlin.test)
  androidTestImplementation(libs.kotlin.time)
  androidTestImplementation(libs.test.assertk)
  androidTestImplementation(libs.test.junit)
}


================================================
FILE: android-test/multidex-config.pro
================================================
-keep class okio.** { *; }


================================================
FILE: android-test/src/main/AndroidManifest.xml
================================================
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="MissingClass"
    >

  <uses-permission android:name="android.permission.INTERNET" />

  <!-- To access the system temporary directory. -->
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

  <application
      android:name="androidx.multidex.MultiDexApplication"
      android:usesCleartextTraffic="true" />

</manifest>


================================================
FILE: android-test/src/main/res/values/strings.xml
================================================
<resources>
  <string name="app_name">android-test</string>
</resources>


================================================
FILE: android-test/src/main/res/xml/network_security_config.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
  <base-config cleartextTrafficPermitted="false">
  </base-config>
</network-security-config>


================================================
FILE: build-support/build.gradle.kts
================================================
plugins {
  `kotlin-dsl`
  `java-gradle-plugin`
}

repositories {
  mavenCentral()
}

dependencies {
  add("compileOnly", kotlin("gradle-plugin"))
  add("compileOnly", kotlin("gradle-plugin-api"))
}

gradlePlugin {
  plugins {
    create("build-support") {
      id = "build-support"
      implementationClass = "BuildSupport"
    }
  }
}

dependencies {
  implementation(libs.kotlin.gradle.plugin)
  implementation(libs.tapmoc.gradle.plugin)
}


================================================
FILE: build-support/settings.gradle.kts
================================================
dependencyResolutionManagement {
  versionCatalogs {
    create("libs") {
      from(files("../gradle/libs.versions.toml"))
    }
  }
}


================================================
FILE: build-support/src/main/kotlin/BuildSupport.kt
================================================
/*
 * Copyright (C) 2023 Square, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import java.nio.charset.StandardCharsets
import org.gradle.api.GradleException
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalog
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.api.tasks.compile.JavaCompile
import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import tapmoc.configureKotlinCompatibility

class BuildSupport : Plugin<Project> {
  override fun apply(project: Project) {
    project.configureKotlinCompatibility(project.getVersionByName("kotlinCoreLibrariesVersion"))

    // `project.configureJavaCompatibility(8)` is not used as the code would compile with JDK 8.
    // This will fail as `RealBufferedSource.kt` uses a Java API not available in Java 8:` InputStream.transferTo`
    // To use `project.configureJavaCompatibility`, the min supported Java version would need to be bumped to 11
    project.tasks.withType(KotlinCompile::class.java).configureEach {
      compilerOptions {
        jvmTarget.set(JvmTarget.JVM_1_8)
        jvmDefault.set(JvmDefaultMode.NO_COMPATIBILITY)
      }
    }
    project.tasks.withType(JavaCompile::class.java) {
      options.encoding = StandardCharsets.UTF_8.toString()
      sourceCompatibility = JavaVersion.VERSION_1_8.toString()
      targetCompatibility = JavaVersion.VERSION_1_8.toString()
    }
  }
}

val Project.versionCatalog: VersionCatalog
  get() = project.extensions.getByType(VersionCatalogsExtension::class.java).find("libs").get()

fun Project.getVersionByName(name: String): String {
  val version = versionCatalog.findVersion(name)
  return if (version.isPresent) {
    version.get().requiredVersion
  } else {
    throw GradleException("Could not find a version for `$name`")
  }
}


================================================
FILE: build-support/src/main/kotlin/bom.kt
================================================
/*
 * Copyright (C) 2023 Square, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import java.util.Locale
import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.DependencyConstraintHandler
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
import org.jetbrains.kotlin.gradle.plugin.KotlinJsPluginWrapper
import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget

/**
 * Collect all the root project's multiplatform targets and add them to the BOM.
 *
 * Only published subprojects are included.
 *
 * This supports Kotlin/Multiplatform and Kotlin/JS subprojects.
 */
fun Project.collectBomConstraints() {
  val bomConstraints: DependencyConstraintHandler = dependencies.constraints
  rootProject.subprojects {
    val subproject = this

    subproject.plugins.withId("com.vanniktech.maven.publish.base") {
      subproject.plugins.withType<KotlinAndroidPluginWrapper> {
        bomConstraints.api(subproject)
      }

      subproject.plugins.withType<KotlinJsPluginWrapper> {
        bomConstraints.api(subproject)
      }

      subproject.plugins.withType<KotlinMultiplatformPluginWrapper> {
        subproject.extensions.getByType<KotlinMultiplatformExtension>().targets.all {
          bomConstraints.api(dependencyConstraint(this))
        }
      }
    }
  }
}

/** Returns a string like "com.squareup.okio:okio-iosarm64:3.4.0" for this target. */
private fun Project.dependencyConstraint(target: KotlinTarget): String {
  val artifactId = when (target) {
    is KotlinMetadataTarget -> name
    else -> "$name-${target.targetName.lowercase(Locale.ROOT)}"
  }
  return "$group:$artifactId:$version"
}

private fun DependencyConstraintHandler.api(constraintNotation: Any) =
  add("api", constraintNotation)


================================================
FILE: build-support/src/main/kotlin/jvm.kt
================================================
/*
 * Copyright (C) 2023 Square, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// If true - tests should run for a loom environment.
val loomEnabled = System.getProperty("loomEnabled", "false").toBoolean()


================================================
FILE: build-support/src/main/kotlin/kmp.kt
================================================
/*
 * Copyright (C) 2023 Square, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// If false - JS targets will not be configured in multiplatform projects.
val kmpJsEnabled = System.getProperty("kjs", "true").toBoolean()

// If false - Native targets will not be configured in multiplatform projects.
val kmpNativeEnabled = System.getProperty("knative", "true").toBoolean()

// If false - WASM targets will not be configured in multiplatform projects.
val kmpWasmEnabled = System.getProperty("kwasm", "true").toBoolean()


================================================
FILE: build-support/src/main/kotlin/platforms.kt
================================================
/*
 * Copyright (C) 2023 Square, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import org.gradle.api.NamedDomainObjectContainer
import org.gradle.kotlin.dsl.get
import org.jetbrains.kotlin.gradle.dsl.JsModuleKind.MODULE_UMD
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet

fun KotlinMultiplatformExtension.configureOrCreateOkioPlatforms() {
  jvm {
  }
  if (kmpJsEnabled) {
    configureOrCreateJsPlatforms()
  }
  if (kmpNativeEnabled) {
    configureOrCreateNativePlatforms()
  }
  if (kmpWasmEnabled) {
    configureOrCreateWasmPlatform()
  }
}

fun KotlinMultiplatformExtension.configureOrCreateNativePlatforms() {
  iosX64()
  iosArm64()
  iosSimulatorArm64()
  tvosX64()
  tvosArm64()
  tvosSimulatorArm64()
  watchosArm32()
  watchosArm64()
  watchosDeviceArm64()
  watchosX64()
  watchosSimulatorArm64()
  // Required to generate tests tasks: https://youtrack.jetbrains.com/issue/KT-26547
  linuxX64()
  linuxArm64()
  macosX64()
  macosArm64()
  mingwX64()
}

val appleTargets = listOf(
  "iosArm64",
  "iosX64",
  "iosSimulatorArm64",
  "macosX64",
  "macosArm64",
  "tvosArm64",
  "tvosX64",
  "tvosSimulatorArm64",
  "watchosArm32",
  "watchosArm64",
  "watchosDeviceArm64",
  "watchosX64",
  "watchosSimulatorArm64",
)

val mingwTargets = listOf(
  "mingwX64",
)

val linuxTargets = listOf(
  "linuxX64",
  "linuxArm64",
)

val nativeTargets = appleTargets + linuxTargets + mingwTargets

val wasmTargets = listOf(
  "wasmJs",
  "wasmWasi",
)

/**
 * Creates a source set for a directory that isn't already a built-in platform. Use this to create
 * custom shared directories like `nonJvmMain` or `unixMain`.
 */
fun NamedDomainObjectContainer<KotlinSourceSet>.createSourceSet(
  name: String,
  parent: KotlinSourceSet? = null,
  children: List<String> = listOf()
): KotlinSourceSet {
  val result = create(name)

  if (parent != null) {
    result.dependsOn(parent)
  }

  val suffix = when {
    name.endsWith("Main") -> "Main"
    name.endsWith("Test") -> "Test"
    else -> error("unexpected source set name: ${name}")
  }

  for (childTarget in children) {
    val childSourceSet = get("${childTarget}$suffix")
    childSourceSet.dependsOn(result)
  }

  return result
}

fun KotlinMultiplatformExtension.configureOrCreateJsPlatforms() {
  js {
    compilerOptions {
      moduleKind.set(MODULE_UMD)
      sourceMap.set(true)
    }
    nodejs {
      testTask {
        useMocha {
          timeout = "30s"
        }
      }
    }
    browser {
    }
  }
}

fun KotlinMultiplatformExtension.configureOrCreateWasmPlatform(
  js: Boolean = true,
  wasi: Boolean = true,
) {
  if (js) {
    wasmJs {
      nodejs()
    }
  }
  if (wasi) {
    wasmWasi {
      nodejs()
    }
  }
}


================================================
FILE: build.gradle.kts
================================================
import aQute.bnd.gradle.BundleTaskExtension
import com.diffplug.gradle.spotless.SpotlessExtension
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import groovy.util.Node
import groovy.util.NodeList
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED
import org.gradle.api.tasks.testing.logging.TestLogEvent.STARTED
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile

plugins {
  id("build-support").apply(false)
}

buildscript {
  dependencies {
    classpath(libs.android.gradle.plugin)
    classpath(libs.burst.gradle.plugin)
    classpath(libs.dokka)
    classpath(libs.jmh.gradle.plugin)
    classpath(libs.binaryCompatibilityValidator)
    classpath(libs.spotless)
    classpath(libs.bnd)
    classpath(libs.vanniktech.publish.plugin)
    classpath(libs.tapmoc.gradle.plugin)
  }

  repositories {
    mavenCentral()
    gradlePluginPortal()
    google()
  }
}

apply(plugin = "com.vanniktech.maven.publish.base")

// When scripts are applied the buildscript classes are not accessible directly therefore we save
// the class here to make it accessible.
ext.set("bndBundleTaskExtensionClass", BundleTaskExtension::class.java)

allprojects {
  group = project.property("GROUP") as String
  version = project.property("VERSION_NAME") as String

  repositories {
    mavenCentral()
    google()
  }

  tasks.withType<DokkaTask>().configureEach {
    dokkaSourceSets.configureEach {
      reportUndocumented.set(false)
      skipDeprecated.set(true)
      jdkVersion.set(8)
      perPackageOption {
        matchingRegex.set("com\\.squareup.okio.*")
        suppress.set(true)
      }
      perPackageOption {
        matchingRegex.set("okio\\.internal.*")
        suppress.set(true)
      }
    }

    if (name == "dokkaHtml") {
      outputDirectory.set(file("${rootDir}/docs/3.x/${project.name}"))
      pluginsMapConfiguration.set(
        mapOf(
          "org.jetbrains.dokka.base.DokkaBase" to """
          {
            "customStyleSheets": [
              "${rootDir.toString().replace('\\', '/')}/docs/css/dokka-logo.css"
            ],
            "customAssets" : [
              "${rootDir.toString().replace('\\', '/')}/docs/images/icon-square.png"
            ]
          }
          """.trimIndent()
        )
      )
    }
  }

  plugins.withId("com.vanniktech.maven.publish.base") {
    configure<PublishingExtension> {
      repositories {
        /**
         * Want to push to an internal repository for testing? Set the following properties in
         * `~/.gradle/gradle.properties`.
         *
         * internalMavenUrl=YOUR_INTERNAL_MAVEN_REPOSITORY_URL
         * internalMavenUsername=YOUR_USERNAME
         * internalMavenPassword=YOUR_PASSWORD
         */
        val internalUrl = providers.gradleProperty("internalUrl")
        if (internalUrl.isPresent) {
          maven {
            name = "internal"
            setUrl(internalUrl)
            credentials(PasswordCredentials::class)
          }
        }
      }
    }
    val publishingExtension = extensions.getByType(PublishingExtension::class.java)
    configure<MavenPublishBaseExtension> {
      publishToMavenCentral(automaticRelease = true)
      signAllPublications()
      pom {
        description.set("A modern I/O library for Android, Java, and Kotlin Multiplatform.")
        name.set(project.name)
        url.set("https://github.com/square/okio/")
        licenses {
          license {
            name.set("The Apache Software License, Version 2.0")
            url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
            distribution.set("repo")
          }
        }
        scm {
          url.set("https://github.com/square/okio/")
          connection.set("scm:git:git://github.com/square/okio.git")
          developerConnection.set("scm:git:ssh://git@github.com/square/okio.git")
        }
        developers {
          developer {
            id.set("square")
            name.set("Square, Inc.")
          }
        }
      }

      // Configure the kotlinMultiplatform artifact to depend on the JVM artifact in pom.xml only.
      // This hack allows Maven users to continue using our original Okio artifact names (like
      // com.squareup.okio:okio:3.x.y) even though we changed that artifact from JVM-only to Kotlin
      // Multiplatform. Note that module.json doesn't need this hack.
      val mavenPublications = publishingExtension.publications.withType<MavenPublication>()
      mavenPublications.configureEach {
        if (name != "jvm") return@configureEach
        val jvmPublication = this
        val kmpPublication = mavenPublications.getByName("kotlinMultiplatform")
        kmpPublication.pom.withXml {
          val root = asNode()
          val dependencies = (root["dependencies"] as NodeList).firstOrNull() as Node?
            ?: root.appendNode("dependencies")
          for (child in dependencies.children().toList()) {
            dependencies.remove(child as Node)
          }
          dependencies.appendNode("dependency").apply {
            appendNode("groupId", jvmPublication.groupId)
            appendNode("artifactId", jvmPublication.artifactId)
            appendNode("version", jvmPublication.version)
            appendNode("scope", "compile")
          }
        }
      }
    }
  }
}

subprojects {
  apply(plugin = "com.diffplug.spotless")
  configure<SpotlessExtension> {
    kotlin {
      target("**/*.kt")
      ktlint(libs.versions.ktlint.get())
    }
  }

  tasks.withType<AbstractKotlinCompile<*>>().configureEach {
    compilerOptions.apply {
      freeCompilerArgs.add("-Xexpect-actual-classes")
    }
  }

  val testJavaVersion = System.getProperty("test.java.version", "").toIntOrNull()
  tasks.withType<Test> {
    val javaToolchains = project.extensions.getByType<JavaToolchainService>()
    if (testJavaVersion != null) {
      javaLauncher.set(javaToolchains.launcherFor {
        languageVersion.set(JavaLanguageVersion.of(testJavaVersion))
      })
    }

    testLogging {
      events(STARTED, PASSED, SKIPPED, FAILED)
      exceptionFormat = TestExceptionFormat.FULL
      showStandardStreams = false
    }

    if (loomEnabled) {
      jvmArgs = jvmArgs!! + listOf(
        "-Djdk.tracePinnedThread=full",
        "--enable-preview",
        "-DloomEnabled=true"
      )
    }
  }

  tasks.withType<AbstractArchiveTask>().configureEach {
    isPreserveFileTimestamps = false
    isReproducibleFileOrder = true
  }

  normalization {
    runtimeClasspath {
      metaInf {
        ignoreAttribute("Bnd-LastModified")
      }
    }
  }
}

/**
 * Set the `OKIO_ROOT` environment variable for tests to access it.
 * https://publicobject.com/2023/04/16/read-a-project-file-in-a-kotlin-multiplatform-test/
 */
allprojects {
  tasks.withType<KotlinJvmTest>().configureEach {
    environment("OKIO_ROOT", rootDir)
  }

  tasks.withType<KotlinNativeTest>().configureEach {
    environment("SIMCTL_CHILD_OKIO_ROOT", rootDir)
    environment("OKIO_ROOT", rootDir)
  }

  tasks.withType<KotlinJsTest>().configureEach {
    environment("OKIO_ROOT", rootDir.toString())
  }
}


================================================
FILE: docs/code_of_conduct.md
================================================
Open Source Code of Conduct
===========================

At Square, we are committed to contributing to the open source community and simplifying the process
of releasing and managing open source software. We’ve seen incredible support and enthusiasm from
thousands of people who have already contributed to our projects — and we want to ensure our community
continues to be truly open for everyone.

This code of conduct outlines our expectations for participants, as well as steps to reporting
unacceptable behavior. We are committed to providing a welcoming and inspiring community for all and
expect our code of conduct to be honored.

Square’s open source community strives to:

 * **Be open**: We invite anyone to participate in any aspect of our projects. Our community is
   open, and any responsibility can be carried by a contributor who demonstrates the required
   capacity and competence.

 * **Be considerate**: People use our work, and we depend on the work of others. Consider users and
   colleagues before taking action. For example, changes to code, infrastructure, policy, and
   documentation may negatively impact others.

 * **Be respectful**: We expect people to work together to resolve conflict, assume good intentions,
   and act with empathy. Do not turn disagreements into personal attacks.

 * **Be collaborative**: Collaboration reduces redundancy and improves the quality of our work. We
   strive for transparency within our open source community, and we work closely with upstream
   developers and others in the free software community to coordinate our efforts.

 * **Be pragmatic**: Questions are encouraged and should be asked early in the process to avoid
   problems later. Be thoughtful and considerate when seeking out the appropriate forum for your
   questions. Those who are asked should be responsive and helpful.

 * **Step down considerately**: Members of every project come and go. When somebody leaves or
   disengages from the project, they should make it known and take the proper steps to ensure that
   others can pick up where they left off.

This code is not exhaustive or complete. It serves to distill our common understanding of a
collaborative, shared environment, and goals. We expect it to be followed in spirit as much as in
the letter.

Diversity Statement
-------------------

We encourage everyone to participate and are committed to building a community for all. Although we
may not be able to satisfy everyone, we all agree that everyone is equal.

Whenever a participant has made a mistake, we expect them to take responsibility for it. If someone
has been harmed or offended, it is our responsibility to listen carefully and respectfully, and do
our best to right the wrong.

Although this list cannot be exhaustive, we explicitly honor diversity in age, culture, ethnicity,
gender identity or expression, language, national origin, political beliefs, profession, race,
religion, sexual orientation, socioeconomic status, and technical ability. We will not tolerate
discrimination based on any of the protected characteristics above, including participants with
disabilities.

Reporting Issues
----------------

If you experience or witness unacceptable behavior — or have any other concerns — please report it by
emailing [codeofconduct@squareup.com][codeofconduct_at]. For more details, please see our Reporting
Guidelines below.

Thanks
------

Some of the ideas and wording for the statements and guidelines above were based on work by the
[Twitter][twitter_coc], [Ubuntu][ubuntu_coc], [GDC][gdc_coc], and [Django][django_coc] communities.
We are thankful for their work.

Reporting Guide
---------------

If you experience or witness unacceptable behavior — or have any other concerns — please report it by
emailing [codeofconduct@squareup.com][codeofconduct_at]. All reports will be handled with
discretion.

In your report please include:

 * Your contact information.
 * Names (real, nicknames, or pseudonyms) of any individuals involved. If there are additional
   witnesses, please include them as well.
 * Your account of what occurred, and if you believe the incident is ongoing. If there is a publicly
   available record (e.g. a mailing list archive or a public IRC logger), please include a link.
 * Any additional information that may be helpful.

After filing a report, a representative from the Square Code of Conduct committee will contact you
personally. The committee will then review the incident, follow up with any additional questions,
and make a decision as to how to respond.

Anyone asked to stop unacceptable behavior is expected to comply immediately. If an individual
engages in unacceptable behavior, the Square Code of Conduct committee may take any action they deem
appropriate, up to and including a permanent ban from all of Square spaces without warning.


[codeofconduct_at]: mailto:codeofconduct@squareup.com
[twitter_coc]: https://github.com/twitter/code-of-conduct/blob/master/code-of-conduct.md
[ubuntu_coc]: https://ubuntu.com/community/code-of-conduct
[gdc_coc]: https://www.gdconf.com/code-of-conduct
[django_coc]: https://www.djangoproject.com/conduct/reporting/



================================================
FILE: docs/css/app.css
================================================
@font-face {
    font-family: cash-market;
    src: url("https://cash-f.squarecdn.com/static/fonts/cash-market/v2/CashMarket-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal
}

@font-face {
    font-family: cash-market;
    src: url("https://cash-f.squarecdn.com/static/fonts/cash-market/v2/CashMarket-Medium.woff2") format("woff2");
    font-weight: 500;
    font-style: normal
}

@font-face {
    font-family: cash-market;
    src: url("https://cash-f.squarecdn.com/static/fonts/cash-market/v2/CashMarket-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal
}

body, input {
    font-family: cash-market,"Helvetica Neue",helvetica,sans-serif;
}

.md-typeset h1, .md-typeset h2, .md-typeset h3, .md-typeset h4 {
    font-family: cash-market,"Helvetica Neue",helvetica,sans-serif;
    line-height: normal;
    font-weight: bold;
    color: var(--md-default-fg-color);
}

button.dl {
  font-weight: 300;
  font-size: 25px;
  line-height: 40px;
  padding: 3px 10px;
  display: inline-block;
  border-radius: 6px;
  color: #f0f0f0;
  margin: 5px 0;
  width: auto;
}

.logo {
  text-align: center;
  margin-top: 150px;
}


================================================
FILE: docs/css/dokka-logo.css
================================================
#logo {
  display: none;
}


================================================
FILE: docs/file_system.md
================================================
File System
===========

Okio's file system is designed to be easy, testable, multiplatform, and efficient.

### Easy

Reading and writing files is concise yet flexible.

```kotlin
val path = "README.md".toPath()

val readmeContent = FileSystem.SYSTEM.read(path) {
  readUtf8()
}

val updatedContent = readmeContent.replace("red", "blue")

FileSystem.SYSTEM.write(path) {
  writeUtf8(updatedContent)
}
```


### Testable

It's easy to swap out the real file system with a fake. This makes tests run faster and more
reliably.

```kotlin
val fileSystem = FakeFileSystem()
val userHome = "/Users/sandy".toPath()
val gitConfig = userHome / ".gitconfig"

fileSystem.createDirectories(userHome)
val original = """
    |[user]
    |  email = sandy@example.com
    |""".trimMargin()
fileSystem.write(gitConfig) { writeUtf8(original) }

GitConfigFixer(fileSystem).fix(userHome)

val expected = """
  |[user]
  |  email = sandy@example.com
  |[diff]
  |  renames = true
  |  indentHeuristic = on
  """.trimIndent()
assertEquals(expected, fileSystem.read(gitConfig) { readUtf8() })
```

With `ForwardingFileSystem` you can easily inject faults to confirm your program is graceful even
when the user's disk fills up.


### Multiplatform

Okio’s `Path` class supports Windows-style (like `C:\autoexec.bat`) and UNIX-style paths
(like `/etc/passwd`). It supports manipulating Windows paths on UNIX, and UNIX paths on Windows.

The system `FileSystem` abstracts over these platform APIs:

 * Android API levels <26: [java.io.File](https://developer.android.com/reference/java/io/File)
 * Java and Android API level 26+: [java.nio.file](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/FileSystem.html)
 * Linux: [man pages](https://www.kernel.org/doc/man-pages/)
 * UNIX: [stdio.h](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdio.h.html)
 * Windows: [fileapi.h](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/)
 * Node.js: [file system](https://nodejs.org/api/fs.html)


### Efficient

Read and write operations integrate with Okio buffers to reduce the number of system calls.

It exposes high-level operations like `atomicMove()` and `metadata` to get the OS to do all the work
when appropriate.


## Known Issues


Okio's implementation is constrained by the capabilities its underlying APIs. This page is an
overview of these limitations.


### All Platforms

 * There are no APIs for file permissions, watches, volume management, memory mapping, or locking.
 * Paths that cannot be represented as UTF-8 strings are unsupported. The underlying APIs that Okio
   calls through, including `java.io.File`, all treat paths as strings.


### Kotlin/JVM

#### On Android, API level less than 26:

 * Creating and accessing symlinks is unsupported.


#### On Windows:

 * `FileSystem.atomicMove()` fails if the target file already exists.


### Kotlin/Native

 * FakeFileSystem does not support concurrent use. We are [holding off on this][fake_fs_concurrency]
   until the upcoming memory model is released.

#### On Windows:

 * Creating and accessing symlinks is unsupported.


### Kotlin/JS

 * NodeJsFileSystem's `source()` and `sink()` cannot access UNIX pipes.
 * Instead of returning null, `NodeJsFileSystem.metadataOrNull()` throws `IOException` if the path
   is invalid. (In the Node.js API there's no mechanism to differentiate between a failure to read
   a valid path and a rejection of an invalid path.)


[fake_fs_concurrency]: https://github.com/square/okio/issues/950


================================================
FILE: docs/index.md
================================================
Okio
====

Okio is a library that complements `java.io` and `java.nio` to make it much
easier to access, store, and process your data. It started as a component of
[OkHttp][1], the capable HTTP client included in Android. It's well-exercised
and ready to solve new problems.

ByteStrings and Buffers
-----------------------

Okio is built around two types that pack a lot of capability into a
straightforward API:

 * [**ByteString**][3] is an immutable sequence of bytes. For character data, `String`
   is fundamental. `ByteString` is String's long-lost brother, making it easy to
   treat binary data as a value. This class is ergonomic: it knows how to encode
   and decode itself as hex, base64, and UTF-8.

 * [**Buffer**][4] is a mutable sequence of bytes. Like `ArrayList`, you don't need
   to size your buffer in advance. You read and write buffers as a queue: write
   data to the end and read it from the front. There's no obligation to manage
   positions, limits, or capacities.

Internally, `ByteString` and `Buffer` do some clever things to save CPU and
memory. If you encode a UTF-8 string as a `ByteString`, it caches a reference to
that string so that if you decode it later, there's no work to do.

`Buffer` is implemented as a linked list of segments. When you move data from
one buffer to another, it _reassigns ownership_ of the segments rather than
copying the data across. This approach is particularly helpful for multithreaded
programs: a thread that talks to the network can exchange data with a worker
thread without any copying or ceremony.

Sources and Sinks
-----------------

An elegant part of the `java.io` design is how streams can be layered for
transformations like encryption and compression. Okio includes its own stream
types called [`Source`][5] and [`Sink`][6] that work like `InputStream` and
`OutputStream`, but with some key differences:

 * **Timeouts.** The streams provide access to the timeouts of the underlying
   I/O mechanism. Unlike the `java.io` socket streams, both `read()` and
   `write()` calls honor timeouts.

 * **Easy to implement.** `Source` declares three methods: `read()`, `close()`,
   and `timeout()`. There are no hazards like `available()` or single-byte reads
   that cause correctness and performance surprises.

 * **Easy to use.** Although _implementations_ of `Source` and `Sink` have only
   three methods to write, _callers_ are given a rich API with the
   [`BufferedSource`][7] and [`BufferedSink`][8] interfaces. These interfaces give you
   everything you need in one place.

 * **No artificial distinction between byte streams and char streams.** It's all
   data. Read and write it as bytes, UTF-8 strings, big-endian 32-bit integers,
   little-endian shorts; whatever you want. No more `InputStreamReader`!

 * **Easy to test.** The `Buffer` class implements both `BufferedSource` and
   `BufferedSink` so your test code is simple and clear.

Sources and sinks interoperate with `InputStream` and `OutputStream`. You can
view any `Source` as an `InputStream`, and you can view any `InputStream` as a
`Source`. Similarly for `Sink` and `OutputStream`.


Presentations
-------------

[A Few “Ok” Libraries][ok_libraries_talk] ([slides][ok_libraries_slides]): An introduction to Okio
and three libraries written with it.

[Decoding the Secrets of Binary Data][encoding_talk] ([slides][encoding_slides]): How data encoding
works and how Okio does it.

[Ok Multiplatform!][ok_multiplatform_talk] ([slides][ok_multiplatform_slides]): How we changed
Okio’s implementation language from Java to Kotlin.

[Nerding Out On Okio][apis_talk]: The story of the Okio APIs, their design and tradeoffs, as well
as implementation notes with animated marbles diagrams.


Requirements
------------

Okio 2.x supports Android 4.0.3+ (API level 15+) and Java 7+.

Okio 3.x supports Android 4.0.3+ (API level 15+) and Java 8+.

Okio depends on the [Kotlin standard library][kotlin]. It is a small library with strong
backward-compatibility.


Releases
--------

Our [change log][changelog] has release history.

```kotlin
implementation("com.squareup.okio:okio:3.17.0")
```

<details>
   <summary>Snapshot builds are also available</summary>

```kotlin
repositories {
  maven("https://central.sonatype.com/repository/maven-snapshots/")
}

dependencies {
  implementation("com.squareup.okio:okio:3.18.0-SNAPSHOT")
}
```

</details>


License
--------

    Copyright 2013 Square, Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

 [1]: https://github.com/square/okhttp
 [3]: https://square.github.io/okio/3.x/okio/okio/okio/-byte-string/index.html
 [4]: https://square.github.io/okio/3.x/okio/okio/okio/-buffer/index.html
 [5]: https://square.github.io/okio/3.x/okio/okio/okio/-source/index.html
 [6]: https://square.github.io/okio/3.x/okio/okio/okio/-sink/index.html
 [7]: https://square.github.io/okio/3.x/okio/okio/okio/-buffered-source/index.html
 [8]: https://square.github.io/okio/3.x/okio/okio/okio/-buffered-sink/index.html
 [changelog]: http://square.github.io/okio/changelog/
 [javadoc]: https://square.github.io/okio/2.x/okio/okio/index.html
 [kotlin]: https://kotlinlang.org/
 [ok_libraries_talk]: https://www.youtube.com/watch?v=WvyScM_S88c
 [ok_libraries_slides]: https://speakerdeck.com/jakewharton/a-few-ok-libraries-droidcon-mtl-2015
 [encoding_talk]: https://www.youtube.com/watch?v=T_p22jMZSrk
 [encoding_slides]: https://speakerdeck.com/swankjesse/decoding-the-secrets-of-binary-data-droidcon-nyc-2016
 [ok_multiplatform_talk]: https://www.youtube.com/watch?v=Q8B4eDirgk0
 [ok_multiplatform_slides]: https://speakerdeck.com/swankjesse/ok-multiplatform
 [apis_talk]: https://www.youtube.com/watch?v=Du7YXPAV1M8


================================================
FILE: docs/java_io_recipes.md
================================================
java.io Recipes
===============

These recipes use Okio with `java.io.File` instead of Okio's own `Path` and `FileSystem` types.


Read a text file line-by-line ([Java][ReadJavaIoFileLineByLine]/[Kotlin][ReadJavaIoFileLineByLineKt])
-----------------------------------------------------------------------------------------------------

This is similar to the other [line-by-line example](recipes.md#read-a-text-file-line-by-line-javakotlin), but it uses `java.io.File`
instead of `okio.Path` and `okio.FileSystem`.

=== "Java"

    ```java
    public void readLines(File file) throws IOException {
      try (Source fileSource = Okio.source(file);
           BufferedSource bufferedFileSource = Okio.buffer(fileSource)) {

        while (true) {
          String line = bufferedFileSource.readUtf8Line();
          if (line == null) break;

          if (line.contains("square")) {
            System.out.println(line);
          }
        }

      }
    }
    ```

=== "Kotlin"

    Note that static `Okio` methods become extension functions (`Okio.source(file)` =>
    `file.source()`).

    ```kotlin
    @Throws(IOException::class)
    fun readLines(file: File) {
      file.source().use { fileSource ->
        fileSource.buffer().use { bufferedFileSource ->
          while (true) {
            val line = bufferedFileSource.readUtf8Line() ?: break
            if ("square" in line) {
              println(line)
            }
          }
        }
      }
    }
    ```

Write a text file ([Java][WriteJavaIoFile]/[Kotlin][WriteJavaIoFileKt])
-----------------------------------------------------------------------------------------------------

This is similar to the other [write example](recipes.md#write-a-text-file-javakotlin), but it uses
`java.io.File` instead of `okio.Path` and `okio.FileSystem`.

=== "Java"

    ```java
    public void writeEnv(File file) throws IOException {
      try (Sink fileSink = Okio.sink(file);
           BufferedSink bufferedSink = Okio.buffer(fileSink)) {

        for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
          bufferedSink.writeUtf8(entry.getKey());
          bufferedSink.writeUtf8("=");
          bufferedSink.writeUtf8(entry.getValue());
          bufferedSink.writeUtf8("\n");
        }

      }
    }
    ```

=== "Kotlin"

    ```kotlin
    @Throws(IOException::class)
    fun writeEnv(file: File) {
      file.sink().buffer().use { sink ->
        for ((key, value) in System.getenv()) {
          sink.writeUtf8(key)
          sink.writeUtf8("=")
          sink.writeUtf8(value)
          sink.writeUtf8("\n")
        }
      }
    }
    ```


[ReadJavaIoFileLineByLineKt]: https://github.com/square/okio/blob/master/samples/src/jvmMain/kotlin/okio/samples/ReadJavaIoFileLineByLine.kt
[ReadJavaIoFileLineByLine]: https://github.com/square/okio/blob/master/samples/src/jvmMain/java/okio/samples/ReadJavaIoFileLineByLine.java
[WriteJavaIoFileKt]: https://github.com/square/okio/blob/master/samples/src/jvmMain/kotlin/okio/samples/WriteJavaIoFile.kt
[WriteJavaIoFile]: https://github.com/square/okio/blob/master/samples/src/jvmMain/java/okio/samples/WriteJavaIoFile.java


================================================
FILE: docs/multiplatform.md
================================================
Multiplatform
=============

Okio is a [Kotlin Multiplatform][kotlin_multiplatform] project. We're still completing our feature
coverage.


### Compression (Deflater, Inflater, Gzip)

JVM and native platforms.


### Concurrency (Pipe, Timeouts, Throttler)

JVM-only.

Timeout is on all platforms, but only the JVM has a useful implementation.


### Core (Buffer, ByteString, Source, Sink)

Available on all platforms.


### File System

Available on all platforms. For JavaScript this requires [Node.js][node_js].


### Hashing

Okio includes Kotlin implementations of MD5, SHA-1, SHA-256, and SHA-512. This includes both hash
functions and HMAC functions.

Okio uses the built-in implementations of these functions on the JVM.


[kotlin_multiplatform]: https://kotlinlang.org/docs/reference/multiplatform.html
[mingw]: http://www.mingw.org/
[node_js]: https://nodejs.org/api/fs.html

## Gradle configuration

```kotlin
// build.gradle.kts
kotlin {
    sourceSets {
        val okioVersion = "3.XXX"
        val commonMain by getting {
            dependencies {
                implementation("com.squareup.okio:okio:$okioVersion")
            }
        }
        val jsMain by getting {
            dependencies {
                implementation("com.squareup.okio:okio-nodefilesystem:$okioVersion")
            }
        }
        val commonTest by getting {
            dependencies {
                implementation("com.squareup.okio:okio-fakefilesystem:$okioVersion")
            }
        }
    }
}
```


================================================
FILE: docs/recipes.md
================================================
Recipes
=======

We've written some recipes that demonstrate how to solve common problems with Okio. Read through
them to learn about how everything works together. Cut-and-paste these examples freely; that's what
they're for.

These recipes work on all platforms: Java, Android, Kotlin/Native, and Kotlin/JS. See
[java.io Recipes](java_io_recipes.md) for samples that integrate Java APIs.


Read a text file line-by-line ([Java][ReadFileLineByLine]/[Kotlin][ReadFileLineByLineKt])
-----------------------------------------------------------------------------------------

Use `FileSystem.source(Path)` to open a source stream to read a file. The returned `Source`
interface is very small and has limited uses. Instead we wrap the source with a buffer. This has two
benefits:

 * **It makes the API more powerful.** Instead of the basic methods offered by `Source`,
   `BufferedSource` has dozens of methods to address most common problems concisely.

 * **It makes your program run faster.** Buffering allows Okio to get more done with fewer I/O
   operations.

Each `Source` that is opened needs to be closed. The code that opens the stream is responsible for
making sure it is closed.

=== "Java"

    Here we use Java's `try` blocks to close our sources automatically.

    ```java
    public void readLines(Path path) throws IOException {
      try (Source fileSource = FileSystem.SYSTEM.source(path);
           BufferedSource bufferedFileSource = Okio.buffer(fileSource)) {

        while (true) {
          String line = bufferedFileSource.readUtf8Line();
          if (line == null) break;

          if (line.contains("square")) {
            System.out.println(line);
          }
        }

      }
    }
    ```

=== "Kotlin"

    This uses `use` to automatically close the streams. This prevents resource leaks, even if an
    exception is thrown.

    ```kotlin
    fun readLines(path: Path) {
      FileSystem.SYSTEM.source(path).use { fileSource ->
        fileSource.buffer().use { bufferedFileSource ->
          while (true) {
            val line = bufferedFileSource.readUtf8Line() ?: break
            if ("square" in line) {
              println(line)
            }
          }
        }
      }
    }
    ```


The `readUtf8Line()` API reads all of the data until the next line delimiter – either `\n`, `\r\n`,
or the end of the file. It returns that data as a string, omitting the delimiter at the end. When it
encounters empty lines the method will return an empty string. If there isn’t any more data to read
it will return null.


=== "Java"

    The above Java program can be written more compactly by inlining the `fileSource` variable and
    by using a fancy `for` loop instead of a `while`:

    ```java
    public void readLines(Path path) throws IOException {
      try (BufferedSource source = Okio.buffer(FileSystem.SYSTEM.source(path))) {
        for (String line; (line = source.readUtf8Line()) != null; ) {
          if (line.contains("square")) {
            System.out.println(line);
          }
        }
      }
    }
    ```

=== "Kotlin"

    In Kotlin, we can use `FileSystem.read()` to buffer the source before our block and close the
    source afterwards. In the body of the block, `this` is a `BufferedSource`.

    ```kotlin
    @Throws(IOException::class)
    fun readLines(path: Path) {
      FileSystem.SYSTEM.read(path) {
        while (true) {
          val line = readUtf8Line() ?: break
          if ("square" in line) {
            println(line)
          }
        }
      }
    }
    ```

The `readUtf8Line()` method is suitable for parsing most files. For certain use-cases you may also
consider `readUtf8LineStrict()`. It is similar but it requires that each line is terminated by `\n`
or `\r\n`. If it encounters the end of the file before that it will throw an `EOFException`. The
strict variant also permits a byte limit to defend against malformed input.

=== "Java"

    ```java
    public void readLines(Path path) throws IOException {
      try (BufferedSource source = Okio.buffer(FileSystem.SYSTEM.source(path))) {
        while (!source.exhausted()) {
          String line = source.readUtf8LineStrict(1024L);
          if (line.contains("square")) {
            System.out.println(line);
          }
        }
      }
    }
    ```

=== "Kotlin"

    ```kotlin
    @Throws(IOException::class)
    fun readLines(path: Path) {
      FileSystem.SYSTEM.read(path) {
        while (!source.exhausted()) {
          val line = source.readUtf8LineStrict(1024)
          if ("square" in line) {
            println(line)
          }
        }
      }
    }
    ```


Write a text file ([Java][WriteFile]/[Kotlin][WriteFileKt])
-----------------------------------------------------------

Above we used a `Source` and a `BufferedSource` to read a file. To write, we use a `Sink` and a
`BufferedSink`. The advantages of buffering are the same: a more capable API and better performance.

```java
public void writeEnv(Path path) throws IOException {
  try (Sink fileSink = FileSystem.SYSTEM.sink(path);
       BufferedSink bufferedSink = Okio.buffer(fileSink)) {

    for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
      bufferedSink.writeUtf8(entry.getKey());
      bufferedSink.writeUtf8("=");
      bufferedSink.writeUtf8(entry.getValue());
      bufferedSink.writeUtf8("\n");
    }

  }
}
```

There isn’t an API to write a line of input; instead we manually insert our own newline character.
Most programs should hardcode `"\n"` as the newline character. In rare situations you may use
`System.lineSeparator()` instead of `"\n"`: it returns `"\r\n"` on Windows and `"\n"` everywhere
else.

=== "Java"

    We can write the above program more compactly by inlining the `fileSink` variable and by taking
    advantage of method chaining:

    ```java
    public void writeEnv(Path path) throws IOException {
      try (BufferedSink sink = Okio.buffer(FileSystem.SYSTEM.sink(path))) {
        for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
          sink.writeUtf8(entry.getKey())
            .writeUtf8("=")
            .writeUtf8(entry.getValue())
            .writeUtf8("\n");
        }
      }
    }
    ```

=== "Kotlin"

    In Kotlin, we can use `FileSystem.write()` to buffer the sink before our block and close the
    sink afterwards. In the body of the block, `this` is a `BufferedSink`.

    ```kotlin
    @Throws(IOException::class)
    fun writeEnv(path: Path) {
      FileSystem.SYSTEM.write(path) {
        for ((key, value) in System.getenv()) {
          writeUtf8(key)
          writeUtf8("=")
          writeUtf8(value)
          writeUtf8("\n")
        }
      }
    }
    ```

In the above code we make four calls to `writeUtf8()`. Making four calls is more efficient than the
code below because the VM doesn’t have to create and garbage collect a temporary string.

```java
sink.writeUtf8(entry.getKey() + "=" + entry.getValue() + "\n"); // Slower!
```


UTF-8 ([Java][ExploreCharsets]/[Kotlin][ExploreCharsetsKt])
-----------------------------------------------------------

In the above APIs you can see that Okio really likes UTF-8. Early computer systems suffered many
incompatible character encodings: ISO-8859-1, ShiftJIS, ASCII, EBCDIC, etc. Writing software to
support multiple character sets was awful and we didn’t even have emoji! Today we're lucky that the
world has standardized on UTF-8 everywhere, with some rare uses of other charsets in legacy systems.

If you need another character set, `readString()` and `writeString()` are there for you. These
 methods require that you specify a character set. Otherwise you may accidentally create data that
 is only readable by the local computer. Most programs should use the UTF-8 methods only.

When encoding strings you need to be mindful of the different ways that strings are represented and
encoded. When a glyph has an accent or another adornment it may be represented as a single complex
 code point (`é`) or as a simple code point (`e`) followed by its modifiers (`´`). When the entire
 glyph is a single code point that’s called [NFC][nfc]; when it’s multiple it’s [NFD][nfd].

Though we use UTF-8 whenever we read or write strings in I/O, when they are in memory Java Strings
use an obsolete character encoding called UTF-16. It is a bad encoding because it uses a 16-bit
`char` for most characters, but some don’t fit. In particular, most emoji use two Java chars. This
is problematic because `String.length()` returns a surprising result: the number of UTF-16 chars and
not the natural number of glyphs.

|                       | Café 🍩                     | Café 🍩                        |
| --------------------: | :---------------------------| :------------------------------|
|                  Form | [NFC][nfc]                  | [NFD][nfd]                     |
|           Code Points | `c  a  f  é    ␣   🍩     ` | `c  a  f  e  ´    ␣   🍩     ` |
|           UTF-8 bytes | `43 61 66 c3a9 20 f09f8da9` | `43 61 66 65 cc81 20 f09f8da9` |
| String.codePointCount | 6                           | 7                              |
|         String.length | 7                           | 8                              |
|             Utf8.size | 10                          | 11                             |

For the most part Okio lets you ignore these problems and focus on your data. But when you need
them, there are convenient APIs for dealing with low-level UTF-8 strings.

Use `Utf8.size()` to count the number of bytes required to encode a string as UTF-8 without actually
encoding it. This is handy in length-prefixed encodings like protocol buffers.

Use `BufferedSource.readUtf8CodePoint()` to read a single variable-length code point, and
`BufferedSink.writeUtf8CodePoint()` to write one.


=== "Java"

    ```java
    public void dumpStringData(String s) throws IOException {
      System.out.println("                       " + s);
      System.out.println("        String.length: " + s.length());
      System.out.println("String.codePointCount: " + s.codePointCount(0, s.length()));
      System.out.println("            Utf8.size: " + Utf8.size(s));
      System.out.println("          UTF-8 bytes: " + ByteString.encodeUtf8(s).hex());
      System.out.println();
    }
    ```

=== "Kotlin"

    ```kotlin
    fun dumpStringData(s: String) {
      println("                       " + s)
      println("        String.length: " + s.length)
      println("String.codePointCount: " + s.codePointCount(0, s.length))
      println("            Utf8.size: " + s.utf8Size())
      println("          UTF-8 bytes: " + s.encodeUtf8().hex())
      println()
    }
    ```

Golden Values ([Java][GoldenValue]/[Kotlin][GoldenValueKt])
-----------------------------------------------------------

Okio likes testing. The library itself is heavily tested, and it has features that are often helpful
when testing application code. One pattern we’ve found to be quite useful is “golden value” testing.
The goal of such tests is to confirm that data encoded with earlier versions of a program can safely
be decoded by the current program.

We’ll illustrate this by encoding a value using Java Serialization. Though we must disclaim that
Java Serialization is an awful encoding system and most programs should prefer other formats like
JSON or protobuf! In any case, here’s a method that takes an object, serializes it, and returns the
result as a `ByteString`:

=== "Java"

    ```Java
    private ByteString serialize(Object o) throws IOException {
      Buffer buffer = new Buffer();
      try (ObjectOutputStream objectOut = new ObjectOutputStream(buffer.outputStream())) {
        objectOut.writeObject(o);
      }
      return buffer.readByteString();
    }
    ```

=== "Kotlin"

    ```Kotlin
    @Throws(IOException::class)
    private fun serialize(o: Any?): ByteString {
      val buffer = Buffer()
      ObjectOutputStream(buffer.outputStream()).use { objectOut ->
        objectOut.writeObject(o)
      }
      return buffer.readByteString()
    }
    ```

There’s a lot going on here.

1. We create a buffer as a holding space for our serialized data. It’s a convenient replacement for
   `ByteArrayOutputStream`.

2. We ask the buffer for its output stream. Writes to a buffer or its output stream always append
   data to the end of the buffer.

3. We create an `ObjectOutputStream` (the encoding API for Java serialization) and write our object.
   The try block takes care of closing the stream for us. Note that closing a buffer has no effect.

4. Finally we read a byte string from the buffer. The `readByteString()` method allows us to specify
   how many bytes to read; here we don’t specify a count in order to read the entire thing. Reads
   from a buffer always consume data from the front of the buffer.

With our `serialize()` method handy we are ready to compute and print a golden value.

=== "Java"

    ```Java
    Point point = new Point(8.0, 15.0);
    ByteString pointBytes = serialize(point);
    System.out.println(pointBytes.base64());
    ```

=== "Kotlin"

    ```Kotlin
    val point = Point(8.0, 15.0)
    val pointBytes = serialize(point)
    println(pointBytes.base64())
    ```

We print the `ByteString` as [base64][base64] because it’s a compact format that’s suitable for
embedding in a test case. The program prints this:

```
rO0ABXNyAB5va2lvLnNhbXBsZXMuR29sZGVuVmFsdWUkUG9pbnTdUW8rMji1IwIAAkQAAXhEAAF5eHBAIAAAAAAAAEAuAAAAAAAA
```

That’s our golden value! We can embed it in our test case using base64 again to convert it back into
a `ByteString`:

=== "Java"

    ```Java
    ByteString goldenBytes = ByteString.decodeBase64("rO0ABXNyAB5va2lvLnNhbXBsZ"
        + "XMuR29sZGVuVmFsdWUkUG9pbnTdUW8rMji1IwIAAkQAAXhEAAF5eHBAIAAAAAAAAEAuA"
        + "AAAAAAA");
    ```

=== "Kotlin"

    ```Kotlin
    val goldenBytes = ("rO0ABXNyACRva2lvLnNhbXBsZXMuS290bGluR29sZGVuVmFsdWUkUG9pbnRF9yaY7cJ9EwIAA" +
      "kQAAXhEAAF5eHBAIAAAAAAAAEAuAAAAAAAA").decodeBase64()
    ```

The next step is to deserialize the `ByteString` back into our value class. This method reverses the
`serialize()` method above: we append a byte string to a buffer then consume it using an
`ObjectInputStream`:

=== "Java"

    ```Java
    private Object deserialize(ByteString byteString) throws IOException, ClassNotFoundException {
      Buffer buffer = new Buffer();
      buffer.write(byteString);
      try (ObjectInputStream objectIn = new ObjectInputStream(buffer.inputStream())) {
        return objectIn.readObject();
      }
    }
    ```

=== "Kotlin"

    ```Kotlin
    @Throws(IOException::class, ClassNotFoundException::class)
    private fun deserialize(byteString: ByteString): Any? {
      val buffer = Buffer()
      buffer.write(byteString)
      ObjectInputStream(buffer.inputStream()).use { objectIn ->
        return objectIn.readObject()
      }
    }
    ```

Now we can test the decoder against the golden value:

=== "Java"

    ```Java
    ByteString goldenBytes = ByteString.decodeBase64("rO0ABXNyAB5va2lvLnNhbXBsZ"
        + "XMuR29sZGVuVmFsdWUkUG9pbnTdUW8rMji1IwIAAkQAAXhEAAF5eHBAIAAAAAAAAEAuA"
        + "AAAAAAA");
    Point decoded = (Point) deserialize(goldenBytes);
    assertEquals(new Point(8.0, 15.0), decoded);
    ```

=== "Kotlin"

    ```Kotlin
    val goldenBytes = ("rO0ABXNyACRva2lvLnNhbXBsZXMuS290bGluR29sZGVuVmFsdWUkUG9pbnRF9yaY7cJ9EwIAA" +
      "kQAAXhEAAF5eHBAIAAAAAAAAEAuAAAAAAAA").decodeBase64()!!
    val decoded = deserialize(goldenBytes) as Point
    assertEquals(point, decoded)
    ```

With this test we can change the serialization of the `Point` class without
breaking compatibility.


Write a binary file ([Java][BitmapEncoder]/[Kotlin][BitmapEncoderKt])
---------------------------------------------------------------------

Encoding a binary file is not unlike encoding a text file. Okio uses the same `BufferedSink` and
`BufferedSource` bytes for both. This is handy for binary formats that include both byte and
character data.

Writing binary data is more hazardous than text because if you make a mistake it is often quite
difficult to diagnose. Avoid such mistakes by being careful around these traps:

 * **The width of each field.** This is the number of bytes used. Okio doesn't include a mechanism
   to emit partial bytes. If you need that, you’ll need to do your own bit shifting and masking
   before writing.

 * **The endianness of each field.** All fields that have more than one byte have _endianness_:
   whether the bytes are ordered most-significant to least (big endian) or least-significant to most
   (little endian). Okio uses the `Le` suffix for little-endian methods; methods without a suffix
   are big-endian.

 * **Signed vs. Unsigned.** Java doesn’t have unsigned primitive types (except for `char`!) so
   coping with this is often something that happens at the application layer. To make this a little
   easier Okio accepts `int` types for `writeByte()` and `writeShort()`. You can pass an “unsigned”
   byte like 255 and Okio will do the right thing.

| Method       | Width | Endianness |           Value | Encoded Value             |
| :----------- | ----: | :--------- | --------------: | :------------------------ |
| writeByte    |     1 |            |               3 | `03`                      |
| writeShort   |     2 | big        |               3 | `00 03`                   |
| writeInt     |     4 | big        |               3 | `00 00 00 03`             |
| writeLong    |     8 | big        |               3 | `00 00 00 00 00 00 00 03` |
| writeShortLe |     2 | little     |               3 | `03 00`                   |
| writeIntLe   |     4 | little     |               3 | `03 00 00 00`             |
| writeLongLe  |     8 | little     |               3 | `03 00 00 00 00 00 00 00` |
| writeByte    |     1 |            |  Byte.MAX_VALUE | `7f`                      |
| writeShort   |     2 | big        | Short.MAX_VALUE | `7f ff`                   |
| writeInt     |     4 | big        |   Int.MAX_VALUE | `7f ff ff ff`             |
| writeLong    |     8 | big        |  Long.MAX_VALUE | `7f ff ff ff ff ff ff ff` |
| writeShortLe |     2 | little     | Short.MAX_VALUE | `ff 7f`                   |
| writeIntLe   |     4 | little     |   Int.MAX_VALUE | `ff ff ff 7f`             |
| writeLongLe  |     8 | little     |  Long.MAX_VALUE | `ff ff ff ff ff ff ff 7f` |

This code encodes a bitmap following the [BMP file format][bmp].

=== "Java"

    ```Java
    void encode(Bitmap bitmap, BufferedSink sink) throws IOException {
      int height = bitmap.height();
      int width = bitmap.width();

      int bytesPerPixel = 3;
      int rowByteCountWithoutPadding = (bytesPerPixel * width);
      int rowByteCount = ((rowByteCountWithoutPadding + 3) / 4) * 4;
      int pixelDataSize = rowByteCount * height;
      int bmpHeaderSize = 14;
      int dibHeaderSize = 40;

      // BMP Header
      sink.writeUtf8("BM"); // ID.
      sink.writeIntLe(bmpHeaderSize + dibHeaderSize + pixelDataSize); // File size.
      sink.writeShortLe(0); // Unused.
      sink.writeShortLe(0); // Unused.
      sink.writeIntLe(bmpHeaderSize + dibHeaderSize); // Offset of pixel data.

      // DIB Header
      sink.writeIntLe(dibHeaderSize);
      sink.writeIntLe(width);
      sink.writeIntLe(height);
      sink.writeShortLe(1);  // Color plane count.
      sink.writeShortLe(bytesPerPixel * Byte.SIZE);
      sink.writeIntLe(0);    // No compression.
      sink.writeIntLe(16);   // Size of bitmap data including padding.
      sink.writeIntLe(2835); // Horizontal print resolution in pixels/meter. (72 dpi).
      sink.writeIntLe(2835); // Vertical print resolution in pixels/meter. (72 dpi).
      sink.writeIntLe(0);    // Palette color count.
      sink.writeIntLe(0);    // 0 important colors.

      // Pixel data.
      for (int y = height - 1; y >= 0; y--) {
        for (int x = 0; x < width; x++) {
          sink.writeByte(bitmap.blue(x, y));
          sink.writeByte(bitmap.green(x, y));
          sink.writeByte(bitmap.red(x, y));
        }

        // Padding for 4-byte alignment.
        for (int p = rowByteCountWithoutPadding; p < rowByteCount; p++) {
          sink.writeByte(0);
        }
      }
    }
    ```

=== "Kotlin"

    ```Kotlin
    @Throws(IOException::class)
    fun encode(bitmap: Bitmap, sink: BufferedSink) {
      val height = bitmap.height
      val width = bitmap.width
      val bytesPerPixel = 3
      val rowByteCountWithoutPadding = bytesPerPixel * width
      val rowByteCount = (rowByteCountWithoutPadding + 3) / 4 * 4
      val pixelDataSize = rowByteCount * height
      val bmpHeaderSize = 14
      val dibHeaderSize = 40

      // BMP Header
      sink.writeUtf8("BM") // ID.
      sink.writeIntLe(bmpHeaderSize + dibHeaderSize + pixelDataSize) // File size.
      sink.writeShortLe(0) // Unused.
      sink.writeShortLe(0) // Unused.
      sink.writeIntLe(bmpHeaderSize + dibHeaderSize) // Offset of pixel data.

      // DIB Header
      sink.writeIntLe(dibHeaderSize)
      sink.writeIntLe(width)
      sink.writeIntLe(height)
      sink.writeShortLe(1) // Color plane count.
      sink.writeShortLe(bytesPerPixel * Byte.SIZE_BITS)
      sink.writeIntLe(0) // No compression.
      sink.writeIntLe(16) // Size of bitmap data including padding.
      sink.writeIntLe(2835) // Horizontal print resolution in pixels/meter. (72 dpi).
      sink.writeIntLe(2835) // Vertical print resolution in pixels/meter. (72 dpi).
      sink.writeIntLe(0) // Palette color count.
      sink.writeIntLe(0) // 0 important colors.

      // Pixel data.
      for (y in height - 1 downTo 0) {
        for (x in 0 until width) {
          sink.writeByte(bitmap.blue(x, y))
          sink.writeByte(bitmap.green(x, y))
          sink.writeByte(bitmap.red(x, y))
        }

        // Padding for 4-byte alignment.
        for (p in rowByteCountWithoutPadding until rowByteCount) {
          sink.writeByte(0)
        }
      }
    }
    ```

The trickiest part of this program is the format’s required padding. The BMP format expects each row
to begin on a 4-byte boundary so it is necessary to add zeros to maintain the alignment.

Encoding other binary formats is usually quite similar. Some tips:

 * Write tests with golden values! Confirming that your program emits the expected result can make
   debugging easier.
 * Use `Utf8.size()` to compute the number of bytes of an encoded string. This is essential for
   length-prefixed formats.
 * Use `Float.floatToIntBits()` and `Double.doubleToLongBits()` to encode floating point values.


Communicate on a Socket ([Java][SocksProxyServer]/[Kotlin][SocksProxyServerKt])
-------------------------------------------------------------------------------

Note that Okio doesn't yet support sockets on Kotlin/Native or Kotlin/JS.

Sending and receiving data over the network is a bit like writing and reading files. We use
`BufferedSink` to encode output and `BufferedSource` to decode input. Like files, network protocols
can be text, binary, or a mix of both. But there are also some substantial differences between the
network and the file system.

With a file you’re either reading or writing but with the network you can do both! Some protocols
handle this by taking turns: write a request, read a response, repeat. You can implement this kind
of protocol with a single thread. In other protocols you may read and write simultaneously.
Typically you’ll want one dedicated thread for reading. For writing you can use either a dedicated
thread or use `synchronized` so that multiple threads can share a sink. Okio’s streams are not safe
for concurrent use.

Sinks buffer outbound data to minimize I/O operations. This is efficient but it means you must
manually call `flush()` to transmit data. Typically message-oriented protocols flush after each
message. Note that Okio will automatically flush when the buffered data exceeds some threshold. This
is intended to save memory and you shouldn’t rely on it for interactive protocols.

Okio builds on `java.io.Socket` for connectivity. Create your socket as a server or as a client,
then use `Okio.source(Socket)` to read and `Okio.sink(Socket)` to write. These APIs also work with
`SSLSocket`. You should use SSL unless you have a very good reason not to!

Cancel a socket from any thread by calling `Socket.close()`; this will cause its sources and sinks
to immediately fail with an `IOException`. You can also configure timeouts for all socket
operations. You don’t need a reference to the socket to adjust timeouts: `Source` and `Sink` expose
timeouts directly. This API works even if the streams are decorated.

As a complete example of networking with Okio we wrote a [basic SOCKS proxy][SocksProxyServer]
server. Some highlights:

=== "Java"

    ```Java
    Socket fromSocket = ...
    BufferedSource fromSource = Okio.buffer(Okio.source(fromSocket));
    BufferedSink fromSink = Okio.buffer(Okio.sink(fromSocket));
    ```

=== "Kotlin"

    ```Kotlin
    val fromSocket: Socket = ...
    val fromSource = fromSocket.source().buffer()
    val fromSink = fromSocket.sink().buffer()
    ```

Creating sources and sinks for sockets is the same as creating them for files. Once you create a
`Source` or `Sink` for a socket you must not use its `InputStream` or `OutputStream`, respectively.

=== "Java"

    ```Java
    Buffer buffer = new Buffer();
    for (long byteCount; (byteCount = source.read(buffer, 8192L)) != -1; ) {
      sink.write(buffer, byteCount);
      sink.flush();
    }
    ```

=== "Kotlin"

    ```Kotlin
    val buffer = Buffer()
    var byteCount: Long
    while (source.read(buffer, 8192L).also { byteCount = it } != -1L) {
      sink.write(buffer, byteCount)
      sink.flush()
    }
    ```

The above loop copies data from the source to the sink, flushing after each read. If we didn’t need
the flushing we could replace this loop with a single call to `BufferedSink.writeAll(Source)`.

The `8192` argument to `read()` is the maximum number of bytes to read before returning. We could
have passed any value here, but we like 8 KiB because that’s the largest value Okio can do in a
single system call. Most of the time application code doesn’t need to deal with such limits!

=== "Java"

    ```Java
    int addressType = fromSource.readByte() & 0xff;
    int port = fromSource.readShort() & 0xffff;
    ```

=== "Kotlin"

    ```Kotlin
    val addressType = fromSource.readByte().toInt() and 0xff
    val port = fromSource.readShort().toInt() and 0xffff
    ```

Okio uses signed types like `byte` and `short`, but often protocols want unsigned values. The
bitwise `&` operator is Java’s preferred idiom to convert a signed value into an unsigned value.
Here’s a cheat sheet for bytes, shorts, and ints:

| Type  | Signed Range                  | Unsigned Range   | Signed to Unsigned          |
| :---- | :---------------------------: | :--------------- | :-------------------------- |
| byte  | -128..127                     | 0..255           | `int u = s & 0xff;`         |
| short | -32,768..32,767               | 0..65,535        | `int u = s & 0xffff;`       |
| int   | -2,147,483,648..2,147,483,647 | 0..4,294,967,295 | `long u = s & 0xffffffffL;` |

Java has no primitive type that can represent unsigned longs.


Hashing ([Java][Hashing]/[Kotlin][HashingKt])
---------------------------------------------

We’re bombarded by hashing in our lives as Java programmers. Early on we're introduced to the
`hashCode()` method, something we know we need to override otherwise unforeseen bad things happen.
Later we’re shown `LinkedHashMap` and its friends. These build on that `hashCode()` method to
organize data for fast retrieval.

Elsewhere we have cryptographic hash functions. These get used all over the place. HTTPS
certificates, Git commits, BitTorrent integrity checking, and Blockchain blocks all use
cryptographic hashes. Good use of hashes can improve the performance, privacy, security, and
simplicity of an application.

Each cryptographic hash function accepts a variable-length stream of input bytes and produces a
fixed-length byte string value called the “hash”. Hash functions have these important qualities:

 * Deterministic: each input always produces the same output.
 * Uniform: each output byte string is equally likely. It is very difficult to find or create pairs
   of different inputs that yield the same output. This is called a “collision”.
 * Non-reversible: knowing an output doesn't help you to find the input. Note that if you know some
   possible inputs you can hash them to see if their hashes match.
 * Well-known: the hash is implemented everywhere and rigorously understood.

Good hash functions are very cheap to compute (dozens of microseconds) and expensive to reverse
(quintillions of millenia). Steady advances in computing and mathematics have caused once-great hash
functions to become inexpensive to reverse. When choosing a hash function, beware that not all are
created equal! Okio supports these well-known cryptographic hash functions:

 * **MD5**: a 128-bit (16 byte) cryptographic hash. It is both insecure and obsolete because it is
   inexpensive to reverse! This hash is offered because it is popular and convenient for use in
   legacy systems that are not security-sensitive.
 * **SHA-1**: a 160-bit (20 byte) cryptographic hash. It was recently demonstrated that it is
   feasible to create SHA-1 collisions. Consider upgrading from SHA-1 to SHA-256.
 * **SHA-256**: a 256-bit (32 byte) cryptographic hash. SHA-256 is widely understood and expensive
   to reverse. This is the hash most systems should use.
 * **SHA-512**: a 512-bit (64 byte) cryptographic hash. It is expensive to reverse.

Each hash creates a `ByteString` of the specified length. Use `hex()` to get the conventional
human-readable form. Or leave it as a `ByteString` because that’s a convenient model type!

Okio can produce cryptographic hashes from byte strings:

=== "Java"

    ```Java
    ByteString byteString = readByteString(Path.get("README.md"));
    System.out.println("   md5: " + byteString.md5().hex());
    System.out.println("  sha1: " + byteString.sha1().hex());
    System.out.println("sha256: " + byteString.sha256().hex());
    System.out.println("sha512: " + byteString.sha512().hex());
    ```

=== "Kotlin"

    ```Kotlin
    val byteString = readByteString("README.md".toPath())
    println("       md5: " + byteString.md5().hex())
    println("      sha1: " + byteString.sha1().hex())
    println("    sha256: " + byteString.sha256().hex())
    println("    sha512: " + byteString.sha512().hex())
    ```

From buffers:

=== "Java"

    ```Java
    Buffer buffer = readBuffer(Path.get("README.md"));
    System.out.println("   md5: " + buffer.md5().hex());
    System.out.println("  sha1: " + buffer.sha1().hex());
    System.out.println("sha256: " + buffer.sha256().hex());
    System.out.println("sha512: " + buffer.sha512().hex());
    ```

=== "Kotlin"

    ```Kotlin
    val buffer = readBuffer("README.md".toPath())
    println("       md5: " + buffer.md5().hex())
    println("      sha1: " + buffer.sha1().hex())
    println("    sha256: " + buffer.sha256().hex())
    println("    sha512: " + buffer.sha512().hex())
    ```

While streaming from a source:

=== "Java"

    ```Java
    try (HashingSink hashingSink = HashingSink.sha256(Okio.blackhole());
         BufferedSource source = Okio.buffer(FileSystem.SYSTEM.source(path))) {
      source.readAll(hashingSink);
      System.out.println("sha256: " + hashingSink.hash().hex());
    }
    ```

=== "Kotlin"

    ```Kotlin
    sha256(blackholeSink()).use { hashingSink ->
      FileSystem.SYSTEM.source(path).buffer().use { source ->
        source.readAll(hashingSink)
        println("    sha256: " + hashingSink.hash.hex())
      }
    }
    ```

While streaming to a sink:

=== "Java"

    ```Java
    try (HashingSink hashingSink = HashingSink.sha256(Okio.blackhole());
         BufferedSink sink = Okio.buffer(hashingSink);
         Source source = FileSystem.SYSTEM.source(path)) {
      sink.writeAll(source);
      sink.close(); // Emit anything buffered.
      System.out.println("sha256: " + hashingSink.hash().hex());
    }
    ```

=== "Kotlin"

    ```Kotlin
    sha256(blackholeSink()).use { hashingSink ->
      hashingSink.buffer().use { sink ->
        FileSystem.SYSTEM.source(path).use { source ->
          sink.writeAll(source)
          sink.close() // Emit anything buffered.
          println("    sha256: " + hashingSink.hash.hex())
        }
      }
    }
    ```

Okio also supports HMAC (Hash Message Authentication Code) which combines a secret and a hash.
Applications use HMAC for data integrity and authentication.

=== "Java"

    ```Java
    ByteString secret = ByteString.decodeHex("7065616e7574627574746572");
    System.out.println("hmacSha256: " + byteString.hmacSha256(secret).hex());
    ```

=== "Kotlin"

    ```Kotlin
    val secret = "7065616e7574627574746572".decodeHex()
    println("hmacSha256: " + byteString.hmacSha256(secret).hex())
    ```

As with hashing, you can generate an HMAC from a `ByteString`, `Buffer`, `HashingSource`, and
`HashingSink`. Note that Okio doesn’t implement HMAC for MD5.

On Android and Java, Okio uses Java’s `java.security.MessageDigest` for cryptographic hashes and
`javax.crypto.Mac` for HMAC. On other platforms Okio uses its own optimized implementation of
these algorithms.


Encryption and Decryption
-------------------------

On Android and Java it's easy to encrypt streams.

Callers are responsible for the initialization of the encryption or decryption cipher with the
chosen algorithm, the key, and algorithm-specific additional parameters like the initialization
vector. The following example shows a typical usage with AES encryption, in which `key` and `iv`
parameters should both be 16 bytes long.

=== "Java"

    Use `Okio.cipherSink(Sink, Cipher)` or `Okio.cipherSource(Source, Cipher)` to encrypt or decrypt
    a stream using a block cipher.

    ```java
    void encryptAes(ByteString bytes, Path path, byte[] key, byte[] iv)
        throws GeneralSecurityException, IOException {
      Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
      cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"), new IvParameterSpec(iv));
      try (BufferedSink sink = Okio.buffer(
          Okio.cipherSink(FileSystem.SYSTEM.sink(path), cipher))) {
        sink.write(bytes);
      }
    }

    ByteString decryptAesToByteString(Path path, byte[] key, byte[] iv)
        throws GeneralSecurityException, IOException {
      Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
      cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"), new IvParameterSpec(iv));
      try (BufferedSource source = Okio.buffer(
          Okio.cipherSource(FileSystem.SYSTEM.source(path), cipher))) {
        return source.readByteString();
      }
    }
    ```

=== "Kotlin"

    Encryption and decryption functions are extensions on `Cipher`:

    ```kotlin
    fun encryptAes(bytes: ByteString, path: Path, key: ByteArray, iv: ByteArray) {
      val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
      cipher.init(Cipher.ENCRYPT_MODE, SecretKeySpec(key, "AES"), IvParameterSpec(iv))
      val cipherSink = FileSystem.SYSTEM.sink(path).cipherSink(cipher)
      cipherSink.buffer().use {
        it.write(bytes)
      }
    }

    fun decryptAesToByteString(path: Path, key: ByteArray, iv: ByteArray): ByteString {
      val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
      cipher.init(Cipher.DECRYPT_MODE, SecretKeySpec(key, "AES"), IvParameterSpec(iv))
      val cipherSource = FileSystem.SYSTEM.source(path).cipherSource(cipher)
      return cipherSource.buffer().use {
        it.readByteString()
      }
    }
    ```


[base64]: https://tools.ietf.org/html/rfc4648#section-4
[bmp]: https://en.wikipedia.org/wiki/BMP_file_format
[nfd]: https://docs.oracle.com/javase/7/docs/api/java/text/Normalizer.Form.html#NFD
[nfc]: https://docs.oracle.com/javase/7/docs/api/java/text/Normalizer.Form.html#NFC
[BitmapEncoderKt]: https://github.com/square/okio/blob/master/samples/src/jvmMain/kotlin/okio/samples/BitmapEncoder.kt
[BitmapEncoder]: https://github.com/square/okio/blob/master/samples/src/jvmMain/java/okio/samples/BitmapEncoder.java
[ExploreCharsetsKt]: https://github.com/square/okio/blob/master/samples/src/jvmMain/kotlin/okio/samples/ExploreCharsets.kt
[ExploreCharsets]: https://github.com/square/okio/blob/master/samples/src/jvmMain/java/okio/samples/ExploreCharsets.java
[GoldenValueKt]: https://github.com/square/okio/blob/master/samples/src/jvmMain/kotlin/okio/samples/GoldenValue.kt
[GoldenValue]: https://github.com/square/okio/blob/master/samples/src/jvmMain/java/okio/samples/GoldenValue.java
[HashingKt]: https://github.com/square/okio/blob/master/samples/src/jvmMain/kotlin/okio/samples/Hashing.kt
[Hashing]: https://github.com/square/okio/blob/master/samples/src/jvmMain/java/okio/samples/Hashing.java
[ReadFileLineByLine]: https://github.com/square/okio/blob/master/samples/src/jvmMain/java/okio/samples/ReadFileLineByLine.java
[ReadFileLineByLineKt]: https://github.com/square/okio/blob/master/samples/src/jvmMain/kotlin/okio/samples/ReadJavaIoFileLineByLine.kt
[SocksProxyServerKt]: https://github.com/square/okio/blob/master/samples/src/jvmMain/kotlin/okio/samples/SocksProxyServer.kt
[SocksProxyServer]: https://github.com/square/okio/blob/master/samples/src/jvmMain/java/okio/samples/SocksProxyServer.java
[WriteFile]: https://github.com/square/okio/blob/master/samples/src/jvmMain/java/okio/samples/WriteFile.java
[WriteFileKt]: https://github.com/square/okio/blob/master/samples/src/jvmMain/kotlin/okio/samples/WriteFile.kt


================================================
FILE: docs/releasing.md
================================================
Releasing
=========

1. Update `CHANGELOG.md`.

2. Set versions:

    ```
    export RELEASE_VERSION=X.Y.Z
    export NEXT_VERSION=X.Y.Z-SNAPSHOT
    ```

3. Update versions, tag the release, and prepare for the next release.

    ```
    sed -i "" \
      "s/VERSION_NAME=.*/VERSION_NAME=$RELEASE_VERSION/g" \
      gradle.properties
    sed -i "" \
      "s/\"com.squareup.okio:\([^\:]*\):[0-9.]*\"/\"com.squareup.okio:\1:$RELEASE_VERSION\"/g" \
      `find . -name "index.md"`
    sed -i "" \
      "s/\"com.squareup.okio:\([^\:]*\):[0-9.]*-SNAPSHOT\"/\"com.squareup.okio:\1:$NEXT_VERSION\"/g" \
      `find . -name "index.md"`

    git commit -am "Prepare for release $RELEASE_VERSION."
    git tag -a parent-$RELEASE_VERSION -m "Version $RELEASE_VERSION"

    sed -i "" \
      "s/VERSION_NAME=.*/VERSION_NAME=$NEXT_VERSION/g" \
      gradle.properties
    git commit -am "Prepare next development version."

    git push && git push --tags
    ```

4. Wait for [GitHub Actions][github_actions] to build and promote the release.

[github_actions]: https://github.com/square/okio/actions


================================================
FILE: docs/security.md
================================================
Security Policy
===============

## Supported Versions

| Version | Supported  |
| ------- | ---------- |
| 3.x     | ✅         |
| 2.x     | ✅         |
| 1.x     | ✅         |


## Reporting a Vulnerability

Square recognizes the important contributions the security research community
can make. We therefore encourage reporting security issues with the code
contained in this repository.

If you believe you have discovered a security vulnerability, please follow the
guidelines at https://bugcrowd.com/squareopensource


================================================
FILE: gradle/libs.versions.toml
================================================
[versions]
burst = "2.10.2"
jmh = "1.37"
kotlin = "2.2.21"
# Set to lower version than KGP version to maximize compatibility
kotlinCoreLibrariesVersion = "2.1.21"
ktlint = "0.48.2"

[libraries]
android-desugar-jdk-libs = { module = "com.android.tools:desugar_jdk_libs", version = "2.1.5" }
android-gradle-plugin = { module = "com.android.tools.build:gradle", version = "9.0.1" }
androidx-test-ext-junit = { module = "androidx.test.ext:junit", version = "1.3.0" }
androidx-test-runner = { module = "androidx.test:runner", version = "1.7.0" }
binaryCompatibilityValidator = { module = "org.jetbrains.kotlinx.binary-compatibility-validator:org.jetbrains.kotlinx.binary-compatibility-validator.gradle.plugin", version = "0.18.1" }
bnd = { module = "biz.aQute.bnd:biz.aQute.bnd.gradle", version = "7.2.1" }
burst-gradle-plugin = { module = "app.cash.burst:burst-gradle-plugin", version.ref = "burst" }
burst-runtime = { module = "app.cash.burst:burst", version.ref = "burst" }
dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version = "2.1.0" }
jmh-core = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" }
jmh-generator = { module = "org.openjdk.jmh:jmh-generator-annprocess", version.ref = "jmh" }
jmh-gradle-plugin = { module = "me.champeau.jmh:jmh-gradle-plugin", version = "0.7.3" }
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
kotlin-time = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version = "0.7.1-0.6.x-compat" }
spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "8.0.0" }
tapmoc-gradle-plugin = { module =  "com.gradleup.tapmoc:com.gradleup.tapmoc.gradle.plugin", version = "0.4.0"}
test-assertk = "com.willowtreeapps.assertk:assertk:0.28.1"
test-jimfs = "com.google.jimfs:jimfs:1.3.1"
test-junit = { module = "junit:junit", version = "4.13.2" }
vanniktech-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.36.0" }


================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists


================================================
FILE: gradle.properties
================================================
org.gradle.jvmargs='-Dfile.encoding=UTF-8'

android.enableJetifier=false
android.useAndroidX=true
android.defaults.buildfeatures.buildconfig=false
android.defaults.buildfeatures.aidl=false
android.defaults.buildfeatures.renderscript=false
android.defaults.buildfeatures.resvalues=false
android.defaults.buildfeatures.shaders=false

kotlin.mpp.applyDefaultHierarchyTemplate=false
kotlin.mpp.commonizerLogLevel=info
kotlin.mpp.enableCInteropCommonization=true
kotlin.mpp.stability.nowarn=true

GROUP=com.squareup.okio
VERSION_NAME=3.18.0-SNAPSHOT


================================================
FILE: gradlew
================================================
#!/bin/sh

#
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
#   Gradle start up script for POSIX generated by Gradle.
#
#   Important for running:
#
#   (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
#       noncompliant, but you have some other compliant shell such as ksh or
#       bash, then to run this script, type that shell name before the whole
#       command line, like:
#
#           ksh Gradle
#
#       Busybox and similar reduced shells will NOT work, because this script
#       requires all of these POSIX shell features:
#         * functions;
#         * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
#           «${var#prefix}», «${var%suffix}», and «$( cmd )»;
#         * compound commands having a testable exit status, especially «case»;
#         * various built-in commands including «command», «set», and «ulimit».
#
#   Important for patching:
#
#   (2) This script targets any POSIX shell, so it avoids extensions provided
#       by Bash, Ksh, etc; in particular arrays are avoided.
#
#       The "traditional" practice of packing multiple parameters into a
#       space-separated string is a well documented source of bugs and security
#       problems, so this is (mostly) avoided, by progressively accumulating
#       options in "$@", and eventually passing that to Java.
#
#       Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
#       and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
#       see the in-line comments for details.
#
#       There are tweaks for specific operating systems such as AIX, CygWin,
#       Darwin, MinGW, and NonStop.
#
#   (3) This script is generated from the Groovy template
#       https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
#       within the Gradle project.
#
#       You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################

# Attempt to set APP_HOME

# Resolve links: $0 may be a link
app_path=$0

# Need this for daisy-chained symlinks.
while
    APP_HOME=${app_path%"${app_path##*/}"}  # leaves a trailing /; empty if no leading path
    [ -h "$app_path" ]
do
    ls=$( ls -ld "$app_path" )
    link=${ls#*' -> '}
    case $link in             #(
      /*)   app_path=$link ;; #(
      *)    app_path=$APP_HOME$link ;;
    esac
done

# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

warn () {
    echo "$*"
} >&2

die () {
    echo
    echo "$*"
    echo
    exit 1
} >&2

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in                #(
  CYGWIN* )         cygwin=true  ;; #(
  Darwin* )         darwin=true  ;; #(
  MSYS* | MINGW* )  msys=true    ;; #(
  NONSTOP* )        nonstop=true ;;
esac



# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
        # IBM's JDK on AIX uses strange locations for the executables
        JAVACMD=$JAVA_HOME/jre/sh/java
    else
        JAVACMD=$JAVA_HOME/bin/java
    fi
    if [ ! -x "$JAVACMD" ] ; then
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
    fi
else
    JAVACMD=java
    if ! command -v java >/dev/null 2>&1
    then
        die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
    fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
    case $MAX_FD in #(
      max*)
        # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
        # shellcheck disable=SC2039,SC3045
        MAX_FD=$( ulimit -H -n ) ||
            warn "Could not query maximum file descriptor limit"
    esac
    case $MAX_FD in  #(
      '' | soft) :;; #(
      *)
        # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
        # shellcheck disable=SC2039,SC3045
        ulimit -n "$MAX_FD" ||
            warn "Could not set maximum file descriptor limit to $MAX_FD"
    esac
fi

# Collect all arguments for the java command, stacking in reverse order:
#   * args from the command line
#   * the main class name
#   * -classpath
#   * -D...appname settings
#   * --module-path (only if needed)
#   * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.

# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
    APP_HOME=$( cygpath --path --mixed "$APP_HOME" )

    JAVACMD=$( cygpath --unix "$JAVACMD" )

    # Now convert the arguments - kludge to limit ourselves to /bin/sh
    for arg do
        if
            case $arg in                                #(
              -*)   false ;;                            # don't mess with options #(
              /?*)  t=${arg#/} t=/${t%%/*}              # looks like a POSIX filepath
                    [ -e "$t" ] ;;                      #(
              *)    false ;;
            esac
        then
            arg=$( cygpath --path --ignore --mixed "$arg" )
        fi
        # Roll the args list around exactly as many times as the number of
        # args, so each arg winds up back in the position where it started, but
        # possibly modified.
        #
        # NB: a `for` loop captures its iteration list before it begins, so
        # changing the positional parameters here affects neither the number of
        # iterations, nor the values presented in `arg`.
        shift                   # remove old arg
        set -- "$@" "$arg"      # push replacement arg
    done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
#   * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
#     and any embedded shellness will be escaped.
#   * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
#     treated as '${Hostname}' itself on the command line.

set -- \
        "-Dorg.gradle.appname=$APP_BASE_NAME" \
        -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
        "$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
    die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
#   readarray ARGS < <( xargs -n1 <<<"$var" ) &&
#   set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#

eval "set -- $(
        printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
        xargs -n1 |
        sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
        tr '\n' ' '
    )" '"$@"'

exec "$JAVACMD" "$@"


================================================
FILE: gradlew.bat
================================================
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem      https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem  Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

:execute
@rem Setup the command line



@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*

:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega


================================================
FILE: mkdocs.yml
================================================
site_name: Okio
site_url: https://square.github.io/okio
repo_name: Okio
repo_url: https://github.com/square/okio
site_description: "A modern I/O library for Android, Kotlin, and Java."
site_author: Square, Inc.
remote_branch: gh-pages
edit_uri: ""

copyright: 'Copyright &copy; 2019 Square, Inc.'

theme:
  name: 'material'
  favicon: images/icon-square.png
  logo: images/icon-square.png
  palette:
    # Palette toggle for light mode
    - scheme: default
      media: "(prefers-color-scheme: light)"
      primary: 'deep purple'
      accent: 'white'
      toggle:
        icon: material/brightness-7
        name: Switch to dark mode
    # Palette toggle for dark mode
    - scheme: slate
      media: "(prefers-color-scheme: dark)"
      primary: 'deep purple'
      accent: 'white'
      toggle:
        icon: material/brightness-4
        name: Switch to light mode
  icon:
    repo: fontawesome/brands/github

extra:
  social:
    - icon: fontawesome/brands/twitter
      link: https://twitter.com/squareeng
    - icon: fontawesome/brands/stack-overflow
      link: https://stackoverflow.com/questions/tagged/okio?sort=active

extra_css:
  - 'css/app.css'

markdown_extensions:
  - smarty
  - codehilite:
      guess_lang: false
  - footnotes
  - meta
  - toc:
      permalink: true
  - pymdownx.betterem:
      smart_enable: all
  - pymdownx.caret
  - pymdownx.inlinehilite
  - pymdownx.magiclink
  - pymdownx.smartsymbols
  - pymdownx.superfences
  - pymdownx.tabbed:
      alternate_style: true 
  - pymdownx.tilde
  - tables

nav:
  - 'Overview': index.md
  - 'Stack Overflow ⏏': https://stackoverflow.com/questions/tagged/okio?sort=active
  - 'Recipes': recipes.md
  - 'java.io Recipes': java_io_recipes.md
  - '3.x API':
    - 'okio': 3.x/okio/okio/okio/index.html
    - 'fakefilesystem': 3.x/okio-fakefilesystem/okio-fakefilesystem/okio.fakefilesystem/-fake-file-system/index.html
    - 'nodefilesystem': 3.x/okio-nodefilesystem/okio-nodefilesystem/okio/-node-js-file-system/index.html
  - '1.x API ⏏': https://square.github.io/okio/1.x/okio/
  - 'Change Log': changelog.md
  - 'File System': file_system.md
  - 'Multiplatform': multiplatform.md
  - 'Contributing': contributing.md
  - 'Code of Conduct': code_of_conduct.md


================================================
FILE: okio/api/okio.api
================================================
public final class okio/-DeflaterSinkExtensions {
	public static final fun deflate (Lokio/Sink;Ljava/util/zip/Deflater;)Lokio/DeflaterSink;
	public static synthetic fun deflate$default (Lokio/Sink;Ljava/util/zip/Deflater;ILjava/lang/Object;)Lokio/DeflaterSink;
}

public final class okio/-DeprecatedOkio {
	public static final field INSTANCE Lokio/-DeprecatedOkio;
	public final fun appendingSink (Ljava/io/File;)Lokio/Sink;
	public final fun blackhole ()Lokio/Sink;
	public final fun buffer (Lokio/Sink;)Lokio/BufferedSink;
	public final fun buffer (Lokio/Source;)Lokio/BufferedSource;
	public final fun sink (Ljava/io/File;)Lokio/Sink;
	public final fun sink (Ljava/io/OutputStream;)Lokio/Sink;
	public final fun sink (Ljava/net/Socket;)Lokio/Sink;
	public final fun sink (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Lokio/Sink;
	public final fun source (Ljava/io/File;)Lokio/Source;
	public final fun source (Ljava/io/InputStream;)Lokio/Source;
	public final fun source (Ljava/net/Socket;)Lokio/Source;
	public final fun source (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Lokio/Source;
}

public final class okio/-DeprecatedUpgrade {
	public static final fun getOkio ()Lokio/-DeprecatedOkio;
	public static final fun getUtf8 ()Lokio/-DeprecatedUtf8;
}

public final class okio/-DeprecatedUtf8 {
	public static final field INSTANCE Lokio/-DeprecatedUtf8;
	public final fun size (Ljava/lang/String;)J
	public final fun size (Ljava/lang/String;II)J
}

public final class okio/-GzipSinkExtensions {
	public static final fun gzip (Lokio/Sink;)Lokio/GzipSink;
}

public final class okio/-GzipSourceExtensions {
	public static final fun gzip (Lokio/Source;)Lokio/GzipSource;
}

public final class okio/-InflaterSourceExtensions {
	public static final fun inflate (Lokio/Source;Ljava/util/zip/Inflater;)Lokio/InflaterSource;
	public static synthetic fun inflate$default (Lokio/Source;Ljava/util/zip/Inflater;ILjava/lang/Object;)Lokio/InflaterSource;
}

public class okio/AsyncTimeout : okio/Timeout {
	public fun <init> ()V
	public final fun access$newTimeoutException (Ljava/io/IOException;)Ljava/io/IOException;
	public fun cancel ()V
	public final fun enter ()V
	public final fun exit ()Z
	protected fun newTimeoutException (Ljava/io/IOException;)Ljava/io/IOException;
	public final fun sink (Lokio/Sink;)Lokio/Sink;
	public final fun source (Lokio/Source;)Lokio/Source;
	protected fun timedOut ()V
	public final fun withTimeout (Lkotlin/jvm/functions/Function0;)Ljava/lang/Object;
}

public final class okio/Buffer : java/lang/Cloneable, java/nio/channels/ByteChannel, okio/BufferedSink, okio/BufferedSource {
	public final fun -deprecated_getByte (J)B
	public final fun -deprecated_size ()J
	public fun <init> ()V
	public fun buffer ()Lokio/Buffer;
	public final fun clear ()V
	public synthetic fun clone ()Ljava/lang/Object;
	public fun clone ()Lokio/Buffer;
	public fun close ()V
	public final fun completeSegmentByteCount ()J
	public final fun copy ()Lokio/Buffer;
	public final fun copyTo (Ljava/io/OutputStream;)Lokio/Buffer;
	public final fun copyTo (Ljava/io/OutputStream;J)Lokio/Buffer;
	public final fun copyTo (Ljava/io/OutputStream;JJ)Lokio/Buffer;
	public final fun copyTo (Lokio/Buffer;J)Lokio/Buffer;
	public final fun copyTo (Lokio/Buffer;JJ)Lokio/Buffer;
	public static synthetic fun copyTo$default (Lokio/Buffer;Ljava/io/OutputStream;JJILjava/lang/Object;)Lokio/Buffer;
	public static synthetic fun copyTo$default (Lokio/Buffer;Lokio/Buffer;JILjava/lang/Object;)Lokio/Buffer;
	public static synthetic fun copyTo$default (Lokio/Buffer;Lokio/Buffer;JJILjava/lang/Object;)Lokio/Buffer;
	public fun emit ()Lokio/Buffer;
	public synthetic fun emit ()Lokio/BufferedSink;
	public fun emitCompleteSegments ()Lokio/Buffer;
	public synthetic fun emitCompleteSegments ()Lokio/BufferedSink;
	public fun equals (Ljava/lang/Object;)Z
	public fun exhausted ()Z
	public fun flush ()V
	public fun getBuffer ()Lokio/Buffer;
	public final fun getByte (J)B
	public fun hashCode ()I
	public final fun hmacSha1 (Lokio/ByteString;)Lokio/ByteString;
	public final fun hmacSha256 (Lokio/ByteString;)Lokio/ByteString;
	public final fun hmacSha512 (Lokio/ByteString;)Lokio/ByteString;
	public fun indexOf (B)J
	public fun indexOf (BJ)J
	public fun indexOf (BJJ)J
	public fun indexOf (Lokio/ByteString;)J
	public fun indexOf (Lokio/ByteString;J)J
	public fun indexOf (Lokio/ByteString;JJ)J
	public fun indexOfElement (Lokio/ByteString;)J
	public fun indexOfElement (Lokio/ByteString;J)J
	public fun inputStream ()Ljava/io/InputStream;
	public fun isOpen ()Z
	public final fun md5 ()Lokio/ByteString;
	public fun outputStream ()Ljava/io/OutputStream;
	public fun peek ()Lokio/BufferedSource;
	public fun rangeEquals (JLokio/ByteString;)Z
	public fun rangeEquals (JLokio/ByteString;II)Z
	public fun read (Ljava/nio/ByteBuffer;)I
	public fun read (Lokio/Buffer;J)J
	public fun read ([B)I
	public fun read ([BII)I
	public fun readAll (Lokio/Sink;)J
	public final fun readAndWriteUnsafe ()Lokio/Buffer$UnsafeCursor;
	public final fun readAndWriteUnsafe (Lokio/Buffer$UnsafeCursor;)Lokio/Buffer$UnsafeCursor;
	public static synthetic fun readAndWriteUnsafe$default (Lokio/Buffer;Lokio/Buffer$UnsafeCursor;ILjava/lang/Object;)Lokio/Buffer$UnsafeCursor;
	public fun readByte ()B
	public fun readByteArray ()[B
	public fun readByteArray (J)[B
	public fun readByteString ()Lokio/ByteString;
	public fun readByteString (J)Lokio/ByteString;
	public fun readDecimalLong ()J
	public final fun readFrom (Ljava/io/InputStream;)Lokio/Buffer;
	public final fun readFrom (Ljava/io/InputStream;J)Lokio/Buffer;
	public fun readFully (Lokio/Buffer;J)V
	public fun readFully ([B)V
	public fun readHexadecimalUnsignedLong ()J
	public fun readInt ()I
	public fun readIntLe ()I
	public fun readLong ()J
	public fun readLongLe ()J
	public fun readShort ()S
	public fun readShortLe ()S
	public fun readString (JLjava/nio/charset/Charset;)Ljava/lang/String;
	public fun readString (Ljava/nio/charset/Charset;)Ljava/lang/String;
	public final fun readUnsafe ()Lokio/Buffer$UnsafeCursor;
	public final fun readUnsafe (Lokio/Buffer$UnsafeCursor;)Lokio/Buffer$UnsafeCursor;
	public static synthetic fun readUnsafe$default (Lokio/Buffer;Lokio/Buffer$UnsafeCursor;ILjava/lang/Object;)Lokio/Buffer$UnsafeCursor;
	public fun readUtf8 ()Ljava/lang/String;
	public fun readUtf8 (J)Ljava/lang/String;
	public fun readUtf8CodePoint ()I
	public fun readUtf8Line ()Ljava/lang/String;
	public fun readUtf8LineStrict ()Ljava/lang/String;
	public fun readUtf8LineStrict (J)Ljava/lang/String;
	public fun request (J)Z
	public fun require (J)V
	public fun select (Lokio/Options;)I
	public fun select (Lokio/TypedOptions;)Ljava/lang/Object;
	public final fun sha1 ()Lokio/ByteString;
	public final fun sha256 ()Lokio/ByteString;
	public final fun sha512 ()Lokio/ByteString;
	public final fun size ()J
	public fun skip (J)V
	public final fun snapshot ()Lokio/ByteString;
	public final fun snapshot (I)Lokio/ByteString;
	public fun timeout ()Lokio/Timeout;
	public fun toString ()Ljava/lang/String;
	public fun write (Ljava/nio/ByteBuffer;)I
	public fun write (Lokio/Buffer;J)V
	public fun write (Lokio/ByteString;)Lokio/Buffer;
	public synthetic fun write (Lokio/ByteString;)Lokio/BufferedSink;
	public fun write (Lokio/ByteString;II)Lokio/Buffer;
	public synthetic fun write (Lokio/ByteString;II)Lokio/BufferedSink;
	public fun write (Lokio/Source;J)Lokio/Buffer;
	public synthetic fun write (Lokio/Source;J)Lokio/BufferedSink;
	public fun write ([B)Lokio/Buffer;
	public synthetic fun write ([B)Lokio/BufferedSink;
	public fun write ([BII)Lokio/Buffer;
	public synthetic fun write ([BII)Lokio/BufferedSink;
	public fun writeAll (Lokio/Source;)J
	public fun writeByte (I)Lokio/Buffer;
	public synthetic fun writeByte (I)Lokio/BufferedSink;
	public fun writeDecimalLong (J)Lokio/Buffer;
	public synthetic fun writeDecimalLong (J)Lokio/BufferedSink;
	public fun writeHexadecimalUnsignedLong (J)Lokio/Buffer;
	public synthetic fun writeHexadecimalUnsignedLong (J)Lokio/BufferedSink;
	public fun writeInt (I)Lokio/Buffer;
	public synthetic fun writeInt (I)Lokio/BufferedSink;
	public fun writeIntLe (I)Lokio/Buffer;
	public synthetic fun writeIntLe (I)Lokio/BufferedSink;
	public fun writeLong (J)Lokio/Buffer;
	public synthetic fun writeLong (J)Lokio/BufferedSink;
	public fun writeLongLe (J)Lokio/Buffer;
	public synthetic fun writeLongLe (J)Lokio/BufferedSink;
	public fun writeShort (I)Lokio/Buffer;
	public synthetic fun writeShort (I)Lokio/BufferedSink;
	public fun writeShortLe (I)Lokio/Buffer;
	public synthetic fun writeShortLe (I)Lokio/BufferedSink;
	public fun writeString (Ljava/lang/String;IILjava/nio/charset/Charset;)Lokio/Buffer;
	public synthetic fun writeString (Ljava/lang/String;IILjava/nio/charset/Charset;)Lokio/BufferedSink;
	public fun writeString (Ljava/lang/String;Ljava/nio/charset/Charset;)Lokio/Buffer;
	public synthetic fun writeString (Ljava/lang/String;Ljava/nio/charset/Charset;)Lokio/BufferedSink;
	public final fun writeTo (Ljava/io/OutputStream;)Lokio/Buffer;
	public final fun writeTo (Ljava/io/OutputStream;J)Lokio/Buffer;
	public static synthetic fun writeTo$default (Lokio/Buffer;Ljava/io/OutputStream;JILjava/lang/Object;)Lokio/Buffer;
	public fun writeUtf8 (Ljava/lang/String;)Lokio/Buffer;
	public synthetic fun writeUtf8 (Ljava/lang/String;)Lokio/BufferedSink;
	public fun writeUtf8 (Ljava/lang/String;II)Lokio/Buffer;
	public synthetic fun writeUtf8 (Ljava/lang/String;II)Lokio/BufferedSink;
	public fun writeUtf8CodePoint (I)Lokio/Buffer;
	public synthetic fun writeUtf8CodePoint (I)Lokio/BufferedSink;
}

public final class okio/Buffer$UnsafeCursor : java/io/Closeable {
	public field buffer Lokio/Buffer;
	public field data [B
	public field end I
	public field offset J
	public field readWrite Z
	public field start I
	public fun <init> ()V
	public fun close ()V
	public final fun expandBuffer (I)J
	public final fun next ()I
	public final fun resizeBuffer (J)J
	public final fun seek (J)I
}

public abstract interface class okio/BufferedSink : java/nio/channels/WritableByteChannel, okio/Sink {
	public abstract fun buffer ()Lokio/Buffer;
	public abstract fun emit ()Lokio/BufferedSink;
	public abstract fun emitCompleteSegments ()Lokio/BufferedSink;
	public abstract fun flush ()V
	public abstract fun getBuffer ()Lokio/Buffer;
	public abstract fun outputStream ()Ljava/io/OutputStream;
	public abstract fun write (Lokio/ByteString;)Lokio/BufferedSink;
	public abstract fun write (Lokio/ByteString;II)Lokio/BufferedSink;
	public abstract fun write (Lokio/Source;J)Lokio/BufferedSink;
	public abstract fun write ([B)Lokio/BufferedSink;
	public abstract fun write ([BII)Lokio/BufferedSink;
	public abstract fun writeAll (Lokio/Source;)J
	public abstract fun writeByte (I)Lokio/BufferedSink;
	public abstract fun writeDecimalLong (J)Lokio/BufferedSink;
	public abstract fun writeHexadecimalUnsignedLong (J)Lokio/BufferedSink;
	public abstract fun writeInt (I)Lokio/BufferedSink;
	public abstract fun writeIntLe (I)Lokio/BufferedSink;
	public abstract fun writeLong (J)Lokio/BufferedSink;
	public abstract fun writeLongLe (J)Lokio/BufferedSink;
	public abstract fun writeShort (I)Lokio/BufferedSink;
	public abstract fun writeShortLe (I)Lokio/BufferedSink;
	public abstract fun writeString (Ljava/lang/String;IILjava/nio/charset/Charset;)Lokio/BufferedSink;
	public abstract fun writeString (Ljava/lang/String;Ljava/nio/charset/Charset;)Lokio/BufferedSink;
	public abstract fun writeUtf8 (Ljava/lang/String;)Lokio/BufferedSink;
	public abstract fun writeUtf8 (Ljava/lang/String;II)Lokio/BufferedSink;
	public abstract fun writeUtf8CodePoint (I)Lokio/BufferedSink;
}

public abstract interface class okio/BufferedSource : java/nio/channels/ReadableByteChannel, okio/Source {
	public abstract fun buffer ()Lokio/Buffer;
	public abstract fun exhausted ()Z
	public abstract fun getBuffer ()Lokio/Buffer;
	public abstract fun indexOf (B)J
	public abstract fun indexOf (BJ)J
	public abstract fun indexOf (BJJ)J
	public abstract fun indexOf (Lokio/ByteString;)J
	public abstract fun indexOf (Lokio/ByteString;J)J
	public abstract fun indexOf (Lokio/ByteString;JJ)J
	public abstract fun indexOfElement (Lokio/ByteString;)J
	public abstract fun indexOfElement (Lokio/ByteString;J)J
	public abstract fun inputStream ()Ljava/io/InputStream;
	public abstract fun peek ()Lokio/BufferedSource;
	public abstract fun rangeEquals (JLokio/ByteString;)Z
	public abstract fun rangeEquals (JLokio/ByteString;II)Z
	public abstract fun read ([B)I
	public abstract fun read ([BII)I
	public abstract fun readAll (Lokio/Sink;)J
	public abstract fun readByte ()B
	public abstract fun readByteArray ()[B
	public abstract fun readByteArray (J)[B
	public abstract fun readByteString ()Lokio/ByteString;
	public abstract fun readByteString (J)Lokio/ByteString;
	public abstract fun readDecimalLong ()J
	public abstract fun readFully (Lokio/Buffer;J)V
	public abstract fun readFully ([B)V
	public abstract fun readHexadecimalUnsignedLong ()J
	public abstract fun readInt ()I
	public abstract fun readIntLe ()I
	public abstract fun readLong ()J
	public abstract fun readLongLe ()J
	public abstract fun readShort ()S
	public abstract fun readShortLe ()S
	public abstract fun readString (JLjava/nio/charset/Charset;)Ljava/lang/String;
	public abstract fun readString (Ljava/nio/charset/Charset;)Ljava/lang/String;
	public abstract fun readUtf8 ()Ljava/lang/String;
	public abstract fun readUtf8 (J)Ljava/lang/String;
	public abstract fun readUtf8CodePoint ()I
	public abstract fun readUtf8Line ()Ljava/lang/String;
	public abstract fun readUtf8LineStrict ()Ljava/lang/String;
	public abstract fun readUtf8LineStrict (J)Ljava/lang/String;
	public abstract fun request (J)Z
	public abstract fun require (J)V
	public abstract fun select (Lokio/Options;)I
	public abstract fun select (Lokio/TypedOptions;)Ljava/lang/Object;
	public abstract fun skip (J)V
}

public class okio/ByteString : java/io/Serializable, java/lang/Comparable {
	public static final field Companion Lokio/ByteString$Companion;
	public static final field EMPTY Lokio/ByteString;
	public final fun -deprecated_getByte (I)B
	public final fun -deprecated_size ()I
	public fun asByteBuffer ()Ljava/nio/ByteBuffer;
	public fun base64 ()Ljava/lang/String;
	public fun base64Url ()Ljava/lang/String;
	public synthetic fun compareTo (Ljava/lang/Object;)I
	public fun compareTo (Lokio/ByteString;)I
	public fun copyInto (I[BII)V
	public static synthetic fun copyInto$default (Lokio/ByteString;I[BIIILjava/lang/Object;)V
	public static final fun decodeBase64 (Ljava/lang/String;)Lokio/ByteString;
	public static final fun decodeHex (Ljava/lang/String;)Lokio/ByteString;
	public static final fun encodeString (Ljava/lang/String;Ljava/nio/charset/Charset;)Lokio/ByteString;
	public static final fun encodeUtf8 (Ljava/lang/String;)Lokio/ByteString;
	public final fun endsWith (Lokio/ByteString;)Z
	public final fun endsWith ([B)Z
	public fun equals (Ljava/lang/Object;)Z
	public final fun getByte (I)B
	public fun hashCode ()I
	public fun hex ()Ljava/lang/String;
	public fun hmacSha1 (Lokio/ByteString;)Lokio/ByteString;
	public fun hmacSha256 (Lokio/ByteString;)Lokio/ByteString;
	public fun hmacSha512 (Lokio/ByteString;)Lokio/ByteString;
	public final fun indexOf (Lokio/ByteString;)I
	public final fun indexOf (Lokio/ByteString;I)I
	public final fun indexOf ([B)I
	public fun indexOf ([BI)I
	public static synthetic fun indexOf$default (Lokio/ByteString;Lokio/ByteString;IILjava/lang/Object;)I
	public static synthetic fun indexOf$default (Lokio/ByteString;[BIILjava/lang/Object;)I
	public final fun lastIndexOf (Lokio/ByteString;)I
	public final fun lastIndexOf (Lokio/ByteString;I)I
	public final fun lastIndexOf ([B)I
	public fun lastIndexOf ([BI)I
	public static synthetic fun lastIndexOf$default (Lokio/ByteString;Lokio/ByteString;IILjava/lang/Object;)I
	public static synthetic fun lastIndexOf$default (Lokio/ByteString;[BIILjava/lang/Object;)I
	public final fun md5 ()Lokio/ByteString;
	public static final fun of (Ljava/nio/ByteBuffer;)Lokio/ByteString;
	public static final fun of ([B)Lokio/ByteString;
	public static final fun of ([BII)Lokio/ByteString;
	public fun rangeEquals (ILokio/ByteString;II)Z
	public fun rangeEquals (I[BII)Z
	public static final fun read (Ljava/io/InputStream;I)Lokio/ByteString;
	public final fun sha1 ()Lokio/ByteString;
	public final fun sha256 ()Lokio/ByteString;
	public final fun sha512 ()Lokio/ByteString;
	public final fun size ()I
	public final fun startsWith (Lokio/ByteString;)Z
	public final fun startsWith ([B)Z
	public fun string (Ljava/nio/charset/Charset;)Ljava/lang/String;
	public final fun substring ()Lokio/ByteString;
	public final fun substring (I)Lokio/ByteString;
	public fun substring (II)Lokio/ByteString;
	public static synthetic fun substring$default (Lokio/ByteString;IIILjava/lang/Object;)Lokio/ByteString;
	public fun toAsciiLowercase ()Lokio/ByteString;
	public fun toAsciiUppercase ()Lokio/ByteString;
	public fun toByteArray ()[B
	public fun toString ()Ljava/lang/String;
	public fun utf8 ()Ljava/lang/String;
	public fun write (Ljava/io/OutputStream;)V
}

public final class okio/ByteString$Companion {
	public final fun -deprecated_decodeBase64 (Ljava/lang/String;)Lokio/ByteString;
	public final fun -deprecated_decodeHex (Ljava/lang/String;)Lokio/ByteString;
	public final fun -deprecated_encodeString (Ljava/lang/String;Ljava/nio/charset/Charset;)Lokio/ByteString;
	public final fun -deprecated_encodeUtf8 (Ljava/lang/String;)Lokio/ByteString;
	public final fun -deprecated_of (Ljava/nio/ByteBuffer;)Lokio/ByteString;
	public final fun -deprecated_of ([BII)Lokio/ByteString;
	public final fun -deprecated_read (Ljava/io/InputStream;I)Lokio/ByteString;
	public final fun decodeBase64 (Ljava/lang/String;)Lokio/ByteString;
	public final fun decodeHex (Ljava/lang/String;)Lokio/ByteString;
	public final fun encodeString (Ljava/lang/String;Ljava/nio/charset/Charset;)Lokio/ByteString;
	public static synthetic fun encodeString$default (Lokio/ByteString$Companion;Ljava/lang/String;Ljava/nio/charset/Charset;ILjava/lang/Object;)Lokio/ByteString;
	public final fun encodeUtf8 (Ljava/lang/String;)Lokio/ByteString;
	public final fun of (Ljava/nio/ByteBuffer;)Lokio/ByteString;
	public final fun of ([B)Lokio/ByteString;
	public final fun of ([BII)Lokio/ByteString;
	public static synthetic fun of$default (Lokio/ByteString$Companion;[BIIILjava/lang/Object;)Lokio/ByteString;
	public final fun read (Ljava/io/InputStream;I)Lokio/ByteString;
}

public final class okio/CipherSink : okio/Sink {
	public fun <init> (Lokio/BufferedSink;Ljavax/crypto/Cipher;)V
	public fun close ()V
	public fun flush ()V
	public final fun getCipher ()Ljavax/crypto/Cipher;
	public fun timeout ()Lokio/Timeout;
	public fun write (Lokio/Buffer;J)V
}

public final class okio/CipherSource : okio/Source {
	public fun <init> (Lokio/BufferedSource;Ljavax/crypto/Cipher;)V
	public fun close ()V
	public final fun getCipher ()Ljavax/crypto/Cipher;
	public fun read (Lokio/Buffer;J)J
	public fun timeout ()Lokio/Timeout;
}

public final class okio/DeflaterSink : okio/Sink {
	public fun <init> (Lokio/Sink;Ljava/util/zip/Deflater;)V
	public fun close ()V
	public fun flush ()V
	public fun timeout ()Lokio/Timeout;
	public fun toString ()Ljava/lang/String;
	public fun write (Lokio/Buffer;J)V
}

public abstract interface annotation class okio/ExperimentalFileSystem : java/lang/annotation/Annotation {
}

public abstract class okio/FileHandle : java/io/Closeable {
	public fun <init> (Z)V
	public final fun appendingSink ()Lokio/Sink;
	public final fun close ()V
	public final fun flush ()V
	public final fun getLock ()Ljava/util/concurrent/locks/ReentrantLock;
	public final fun getReadWrite ()Z
	public final fun position (Lokio/Sink;)J
	public final fun position (Lokio/Source;)J
	protected abstract fun protectedClose ()V
	protected abstract fun protectedFlush ()V
	protected abstract fun protectedRead (J[BII)I
	protected abstract fun protectedResize (J)V
	protected abstract fun protectedSize ()J
	protected abstract fun protectedWrite (J[BII)V
	public final fun read (JLokio/Buffer;J)J
	public final fun read (J[BII)I
	public final fun reposition (Lokio/Sink;J)V
	public final fun reposition (Lokio/Source;J)V
	public final fun resize (J)V
	public final fun sink (J)Lokio/Sink;
	public static synthetic fun sink$default (Lokio/FileHandle;JILjava/lang/Object;)Lokio/Sink;
	public final fun size ()J
	public final fun source (J)Lokio/Source;
	public static synthetic fun source$default (Lokio/FileHandle;JILjava/lang/Object;)Lokio/Source;
	public final fun write (JLokio/Buffer;J)V
	public final fun write (J[BII)V
}

public final class okio/FileMetadata {
	public fun <init> ()V
	public fun <init> (ZZLokio/Path;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/util/Map;)V
	public synthetic fun <init> (ZZLokio/Path;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
	public final fun copy (ZZLokio/Path;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/util/Map;)Lokio/FileMetadata;
	public static synthetic fun copy$default (Lokio/FileMetadata;ZZLokio/Path;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/util/Map;ILjava/lang/Object;)Lokio/FileMetadata;
	public final fun extra (Lkotlin/reflect/KClass;)Ljava/lang/Object;
	public final fun getCreatedAtMillis ()Ljava/lang/Long;
	public final fun getExtras ()Ljava/util/Map;
	public final fun getLastAccessedAtMillis ()Ljava/lang/Long;
	public final fun getLastModifiedAtMillis ()Ljava/lang/Long;
	public final fun getSize ()Ljava/lang/Long;
	public final fun getSymlinkTarget ()Lokio/Path;
	public final fun isDirectory ()Z
	public final fun isRegularFile ()Z
	public fun toString ()Ljava/lang/String;
}

public abstract class okio/FileSystem : java/io/Closeable {
	public static final field Companion Lokio/FileSystem$Companion;
	public static final field RESOURCES Lokio/FileSystem;
	public static final field SYSTEM Lokio/FileSystem;
	public static final field SYSTEM_TEMPORARY_DIRECTORY Lokio/Path;
	public final fun -read (Lokio/Path;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
	public final fun -write (Lokio/Path;ZLkotlin/jvm/functions/Function1;)Ljava/lang/Object;
	public static synthetic fun -write$default (Lokio/FileSystem;Lokio/Path;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object;
	public fun <init> ()V
	public final fun appendingSink (Lokio/Path;)Lokio/Sink;
	public abstract fun appendingSink (Lokio/Path;Z)Lokio/Sink;
	public static synthetic fun appendingSink$default (Lokio/FileSystem;Lokio/Path;ZILjava/lang/Object;)Lokio/Sink;
	public abstract fun atomicMove (Lokio/Path;Lokio/Path;)V
	public abstract fun canonicalize (Lokio/Path;)Lokio/Path;
	public fun close ()V
	public fun copy (Lokio/Path;Lokio/Path;)V
	public final fun createDirectories (Lokio/Path;)V
	public final fun createDirectories (Lokio/Path;Z)V
	public static synthetic fun createDirectories$default (Lokio/FileSystem;Lokio/Path;ZILjava/lang/Object;)V
	public final fun createDirectory (Lokio/Path;)V
	public abstract fun createDirectory (Lokio/Path;Z)V
	public static synthetic fun createDirectory$default (Lokio/FileSystem;Lokio/Path;ZILjava/lang/Object;)V
	public abstract fun createSymlink (Lokio/Path;Lokio/Path;)V
	public final fun delete (Lokio/Path;)V
	public abstract fun delete (Lokio/Path;Z)V
	public static synthetic fun delete$default (Lokio/FileSystem;Lokio/Path;ZILjava/lang/Object;)V
	public final fun deleteRecursively (Lokio/Path;)V
	public fun deleteRecursively (Lokio/Path;Z)V
	public static synthetic fun deleteRecursively$default (Lokio/FileSystem;Lokio/Path;ZILjava/lang/Object;)V
	public final fun exists (Lokio/Path;)Z
	public static final fun get (Ljava/nio/file/FileSystem;)Lokio/FileSystem;
	public abstract fun list (Lokio/Path;)Ljava/util/List;
	public abstract fun listOrNull (Lokio/Path;)Ljava/util/List;
	public final fun listRecursively (Lokio/Path;)Lkotlin/sequences/Sequence;
	public fun listRecursively (Lokio/Path;Z)Lkotlin/sequences/Sequence;
	public static synthetic fun listRecursively$default (Lokio/FileSystem;Lokio/Path;ZILjava/lang/Object;)Lkotlin/sequences/Sequence;
	public final fun metadata (Lokio/Path;)Lokio/FileMetadata;
	public abstract fun metadataOrNull (Lokio/Path;)Lokio/FileMetadata;
	public abstract fun openReadOnly (Lokio/Path;)Lokio/FileHandle;
	public final fun openReadWrite (Lokio/Path;)Lokio/FileHandle;
	public abstract fun openReadWrite (Lokio/Path;ZZ)Lokio/FileHandle;
	public static synthetic fun openReadWrite$default (Lokio/FileSystem;Lokio/Path;ZZILjava/lang/Object;)Lokio/FileHandle;
	public final fun sink (Lokio/Path;)Lokio/Sink;
	public abstract fun sink (Lokio/Path;Z)Lokio/Sink;
	public static synthetic fun sink$default (Lokio/FileSystem;Lokio/Path;ZILjava/lang/Object;)Lokio/Sink;
	public abstract fun source (Lokio/Path;)Lokio/Source;
}

public final class okio/FileSystem$Companion {
	public final fun get (Ljava/nio/file/FileSystem;)Lokio/FileSystem;
}

public abstract class okio/ForwardingFileSystem : okio/FileSystem {
	public fun <init> (Lokio/FileSystem;)V
	public fun appendingSink (Lokio/Path;Z)Lokio/Sink;
	public fun atomicMove (Lokio/Path;Lokio/Path;)V
	public fun canonicalize (Lokio/Path;)Lokio/Path;
	public fun close ()V
	public fun createDirectory (Lokio/Path;Z)V
	public fun createSymlink (Lokio/Path;Lokio/Path;)V
	public final fun delegate ()Lokio/FileSystem;
	public fun delete (Lokio/Path;Z)V
	public fun list (Lokio/Path;)Ljava/util/List;
	public fun listOrNull (Lokio/Path;)Ljava/util/List;
	public fun listRecursively (Lokio/Path;Z)Lkotlin/sequences/Sequence;
	public fun metadataOrNull (Lokio/Path;)Lokio/FileMetadata;
	public fun onPathParameter (Lokio/Path;Ljava/lang/String;Ljava/lang/String;)Lokio/Path;
	public fun onPathResult (Lokio/Path;Ljava/lang/String;)Lokio/Path;
	public fun openReadOnly (Lokio/Path;)Lokio/FileHandle;
	public fun openReadWrite (Lokio/Path;ZZ)Lokio/FileHandle;
	public fun sink (Lokio/Path;Z)Lokio/Sink;
	public fun source (Lokio/Path;)Lokio/Source;
	public fun toString ()Ljava/lang/String;
}

public abstract class okio/ForwardingSink : okio/Sink {
	public final fun -deprecated_delegate ()Lokio/Sink;
	public fun <init> (Lokio/Sink;)V
	public fun close ()V
	public final fun delegate ()Lokio/Sink;
	public fun flush ()V
	public fun timeout ()Lokio/Timeout;
	public fun toString ()Ljava/lang/String;
	public fun write (Lokio/Buffer;J)V
}

public abstract class okio/ForwardingSource : okio/Source {
	public final fun -deprecated_delegate ()Lokio/Source;
	public fun <init> (Lokio/Source;)V
	public fun close ()V
	public final fun delegate ()Lokio/Source;
	public fun read (Lokio/Buffer;J)J
	public fun timeout ()Lokio/Timeout;
	public fun toString ()Ljava/lang/String;
}

public class okio/ForwardingTimeout : okio/Timeout {
	public fun <init> (Lokio/Timeout;)V
	public fun awaitSignal (Ljava/util/concurrent/locks/Condition;)V
	public fun cancel ()V
	public fun clearDeadline ()Lokio/Timeout;
	public fun clearTimeout ()Lokio/Timeout;
	public fun deadlineNanoTime ()J
	public fun deadlineNanoTime (J)Lokio/Timeout;
	public final fun delegate ()Lokio/Timeout;
	public fun hasDeadline ()Z
	public final fun setDelegate (Lokio/Timeout;)Lokio/ForwardingTimeout;
	public final synthetic fun setDelegate (Lokio/Timeout;)V
	public fun throwIfReached ()V
	public fun timeout (JLjava/util/concurrent/TimeUnit;)Lokio/Timeout;
	public fun timeoutNanos ()J
	public fun waitUntilNotified (Ljava/lang/Object;)V
}

public final class okio/GzipSink : okio/Sink {
	public final fun -deprecated_deflater ()Ljava/util/zip/Deflater;
	public fun <init> (Lokio/Sink;)V
	public fun close ()V
	public final fun deflater ()Ljava/util/zip/Deflater;
	public fun flush ()V
	public fun timeout ()Lokio/Timeout;
	public fun write (Lokio/B
Download .txt
gitextract_navft37t/

├── .buildscript/
│   ├── prepare_mkdocs.sh
│   └── restore_v1_docs.sh
├── .editorconfig
├── .gitattributes
├── .github/
│   ├── renovate.json5
│   └── workflows/
│       ├── .java-version
│       ├── build.yml
│       └── release.yaml
├── .gitignore
├── BUG-BOUNTY.md
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE.txt
├── README.md
├── android-test/
│   ├── README.md
│   ├── build.gradle.kts
│   ├── multidex-config.pro
│   └── src/
│       └── main/
│           ├── AndroidManifest.xml
│           └── res/
│               ├── values/
│               │   └── strings.xml
│               └── xml/
│                   └── network_security_config.xml
├── build-support/
│   ├── build.gradle.kts
│   ├── settings.gradle.kts
│   └── src/
│       └── main/
│           └── kotlin/
│               ├── BuildSupport.kt
│               ├── bom.kt
│               ├── jvm.kt
│               ├── kmp.kt
│               └── platforms.kt
├── build.gradle.kts
├── docs/
│   ├── code_of_conduct.md
│   ├── css/
│   │   ├── app.css
│   │   └── dokka-logo.css
│   ├── file_system.md
│   ├── index.md
│   ├── java_io_recipes.md
│   ├── multiplatform.md
│   ├── recipes.md
│   ├── releasing.md
│   └── security.md
├── gradle/
│   ├── libs.versions.toml
│   └── wrapper/
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── mkdocs.yml
├── okio/
│   ├── api/
│   │   └── okio.api
│   ├── build.gradle.kts
│   ├── jvm/
│   │   └── jmh/
│   │       ├── README.md
│   │       ├── build.gradle.kts
│   │       └── src/
│   │           └── jmh/
│   │               └── java/
│   │                   └── com/
│   │                       └── squareup/
│   │                           └── okio/
│   │                               └── benchmarks/
│   │                                   ├── AsyncTimeoutBenchmark.java
│   │                                   ├── BenchmarkUtils.kt
│   │                                   ├── BufferCursorSeekBenchmark.java
│   │                                   ├── BufferPerformanceBenchmark.java
│   │                                   ├── BufferUtf8Benchmark.java
│   │                                   ├── GetByteBenchmark.java
│   │                                   ├── HashFunctionBenchmark.java
│   │                                   ├── IndexOfElementBenchmark.java
│   │                                   ├── ReadByteStringBenchmark.java
│   │                                   ├── SegmentedByteStringBenchmark.java
│   │                                   ├── SelectBenchmark.java
│   │                                   ├── Utf8Benchmark.java
│   │                                   └── WriteHexadecimalBenchmark.java
│   └── src/
│       ├── appleMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── ByteString.kt
│       │           └── SegmentedByteString.kt
│       ├── appleNonMacosX64Main/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── NonMacosX64PosixVariant.kt
│       ├── appleTest/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── AppleByteStringTest.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── Base64.kt
│       │           ├── Buffer.kt
│       │           ├── BufferedSink.kt
│       │           ├── BufferedSource.kt
│       │           ├── ByteString.kt
│       │           ├── CommonPlatform.kt
│       │           ├── ExperimentalFileSystem.kt
│       │           ├── FileHandle.kt
│       │           ├── FileMetadata.kt
│       │           ├── FileSystem.kt
│       │           ├── ForwardingFileSystem.kt
│       │           ├── ForwardingSource.kt
│       │           ├── HashingSink.kt
│       │           ├── HashingSource.kt
│       │           ├── Okio.kt
│       │           ├── Options.kt
│       │           ├── Path.kt
│       │           ├── PeekSource.kt
│       │           ├── RealBufferedSink.kt
│       │           ├── RealBufferedSource.kt
│       │           ├── Segment.kt
│       │           ├── SegmentPool.kt
│       │           ├── SegmentedByteString.kt
│       │           ├── Sink.kt
│       │           ├── Socket.kt
│       │           ├── Source.kt
│       │           ├── Timeout.kt
│       │           ├── TypedOptions.kt
│       │           ├── Utf8.kt
│       │           ├── Util.kt
│       │           └── internal/
│       │               ├── -Utf8.kt
│       │               ├── Buffer.kt
│       │               ├── BufferedSource.kt
│       │               ├── ByteString.kt
│       │               ├── FileSystem.kt
│       │               ├── Path.kt
│       │               ├── RealBufferedSink.kt
│       │               ├── RealBufferedSource.kt
│       │               └── SegmentedByteString.kt
│       ├── commonTest/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── BufferCommonTest.kt
│       │           ├── BufferedSinkFactory.kt
│       │           ├── BufferedSourceFactory.kt
│       │           ├── ByteStringFactory.kt
│       │           ├── ByteStringMoreTests.kt
│       │           ├── ByteStringTest.kt
│       │           ├── CommonBufferTest.kt
│       │           ├── CommonBufferedSinkTest.kt
│       │           ├── CommonBufferedSourceTest.kt
│       │           ├── CommonOkioKotlinTest.kt
│       │           ├── CommonOptionsTest.kt
│       │           ├── CommonRealBufferedSinkTest.kt
│       │           ├── CommonRealBufferedSourceTest.kt
│       │           ├── ForwardingSourceTest.kt
│       │           ├── HashingSinkTest.kt
│       │           ├── HashingSourceTest.kt
│       │           ├── HashingTest.kt
│       │           ├── MockSink.kt
│       │           ├── OkioTesting.kt
│       │           ├── PathTest.kt
│       │           ├── TypedOptionsTest.kt
│       │           ├── UnsafeCursorTest.kt
│       │           └── Utf8KotlinTest.kt
│       ├── hashFunctions/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── internal/
│       │               ├── HashFunction.kt
│       │               ├── Hmac.kt
│       │               ├── Md5.kt
│       │               ├── Sha1.kt
│       │               ├── Sha256.kt
│       │               └── Sha512.kt
│       ├── jsMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── FileSystem.kt
│       │           ├── JsPlatform.kt
│       │           └── internal/
│       │               └── ByteStringJs.kt
│       ├── jvmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── -DeprecatedOkio.kt
│       │           ├── -DeprecatedUtf8.kt
│       │           ├── -JvmPlatform.kt
│       │           ├── AsyncTimeout.kt
│       │           ├── Buffer.kt
│       │           ├── BufferedSink.kt
│       │           ├── BufferedSource.kt
│       │           ├── ByteString.kt
│       │           ├── CipherSink.kt
│       │           ├── CipherSource.kt
│       │           ├── DeflaterSink.kt
│       │           ├── DeprecatedUpgrade.kt
│       │           ├── FileSystem.System.kt
│       │           ├── FileSystem.kt
│       │           ├── ForwardingSink.kt
│       │           ├── ForwardingSource.kt
│       │           ├── ForwardingTimeout.kt
│       │           ├── HashingSink.kt
│       │           ├── HashingSource.kt
│       │           ├── InflaterSource.kt
│       │           ├── JvmFileHandle.kt
│       │           ├── JvmOkio.kt
│       │           ├── JvmSystemFileSystem.kt
│       │           ├── NioFileSystemFileHandle.kt
│       │           ├── NioFileSystemWrappingFileSystem.kt
│       │           ├── NioSystemFileSystem.kt
│       │           ├── Path.kt
│       │           ├── Pipe.kt
│       │           ├── RealBufferedSink.kt
│       │           ├── RealBufferedSource.kt
│       │           ├── SegmentPool.kt
│       │           ├── SegmentedByteString.kt
│       │           ├── Sink.kt
│       │           ├── Throttler.kt
│       │           ├── Timeout.kt
│       │           └── internal/
│       │               ├── -Atomic.kt
│       │               ├── -JavaIo.kt
│       │               ├── -ZlibJvm.kt
│       │               ├── DefaultSocket.kt
│       │               ├── PipeSocket.kt
│       │               └── ResourceFileSystem.kt
│       ├── jvmTest/
│       │   ├── kotlin/
│       │   │   └── okio/
│       │   │       ├── AsyncSocket.kt
│       │   │       ├── AsyncTimeoutTest.kt
│       │   │       ├── AwaitSignalTest.kt
│       │   │       ├── BufferCursorKotlinTest.kt
│       │   │       ├── BufferCursorTest.kt
│       │   │       ├── BufferFactory.kt
│       │   │       ├── BufferKotlinTest.kt
│       │   │       ├── BufferTest.kt
│       │   │       ├── BufferedSinkJavaTest.kt
│       │   │       ├── BufferedSinkTest.kt
│       │   │       ├── BufferedSourceJavaTest.kt
│       │   │       ├── BufferedSourceTest.kt
│       │   │       ├── ByteStringJavaTest.kt
│       │   │       ├── ByteStringKotlinTest.kt
│       │   │       ├── CipherAlgorithm.kt
│       │   │       ├── CipherFactory.kt
│       │   │       ├── CipherSinkTest.kt
│       │   │       ├── CipherSourceTest.kt
│       │   │       ├── DeflateKotlinTest.kt
│       │   │       ├── DeflaterSinkTest.kt
│       │   │       ├── FileHandleFileSystemTest.kt
│       │   │       ├── FileLeakTest.kt
│       │   │       ├── FileSystemJavaTest.kt
│       │   │       ├── FixedLengthSourceTest.kt
│       │   │       ├── ForwardingTimeoutKotlinTest.kt
│       │   │       ├── ForwardingTimeoutTest.kt
│       │   │       ├── InflaterSourceTest.kt
│       │   │       ├── JimfsOkioRoundTripTest.kt
│       │   │       ├── JvmSystemFileSystemTest.kt
│       │   │       ├── JvmTest.kt
│       │   │       ├── JvmTesting.kt
│       │   │       ├── LargeStreamsTest.kt
│       │   │       ├── MessageDigestConsistencyTest.kt
│       │   │       ├── NioTest.kt
│       │   │       ├── OkioKotlinTest.kt
│       │   │       ├── OkioTest.kt
│       │   │       ├── PipeKotlinTest.kt
│       │   │       ├── PipeTest.kt
│       │   │       ├── ReadUtf8LineTest.kt
│       │   │       ├── SegmentSharingTest.kt
│       │   │       ├── SocketTest.kt
│       │   │       ├── SocketTimeoutTest.kt
│       │   │       ├── Stopwatch.kt
│       │   │       ├── TestUtil.kt
│       │   │       ├── ThrottlerTakeTest.kt
│       │   │       ├── ThrottlerTest.kt
│       │   │       ├── TimeoutFactory.kt
│       │   │       ├── TimeoutTest.kt
│       │   │       ├── Utf8Test.kt
│       │   │       ├── WaitUntilNotifiedTest.kt
│       │   │       ├── ZipBuilder.kt
│       │   │       ├── ZipFileSystemJavaTest.kt
│       │   │       └── internal/
│       │   │           ├── HmacTest.kt
│       │   │           ├── PriorityQueueTest.kt
│       │   │           ├── ResourceFileSystemTest.kt
│       │   │           └── SetBitsOrZeroTest.kt
│       │   └── resources/
│       │       └── okio/
│       │           └── resourcefilesystem/
│       │               ├── a.txt
│       │               ├── b/
│       │               │   └── b.txt
│       │               └── non-ascii/
│       │                   └── ギリシア神話/
│       │                       └── Ἰλιάς
│       ├── linuxMain/
│       │   ├── headers/
│       │   │   ├── README.md
│       │   │   ├── include/
│       │   │   │   └── uapi/
│       │   │   │       └── linux/
│       │   │   │           └── stat.h
│       │   │   └── okio_statx.h
│       │   └── kotlin/
│       │       └── okio/
│       │           └── LinuxPosixVariant.kt
│       ├── macosX64Main/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── MacosX64PosixVariant.kt
│       ├── mingwX64Main/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── Windows.kt
│       │           ├── WindowsFileHandle.kt
│       │           └── WindowsPosixVariant.kt
│       ├── nativeMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── Cinterop.kt
│       │           ├── DataProcessor.kt
│       │           ├── Deflater.kt
│       │           ├── DeflaterSink.kt
│       │           ├── FileSink.kt
│       │           ├── FileSource.kt
│       │           ├── FileSystem.kt
│       │           ├── Inflater.kt
│       │           ├── InflaterSource.kt
│       │           ├── PosixFileSystem.kt
│       │           ├── PosixVariant.kt
│       │           ├── SizetVariant.kt
│       │           └── internal/
│       │               ├── -ZlibNative.kt
│       │               └── CRC32.kt
│       ├── nativeTest/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── ByteStringCinteropTest.kt
│       │           ├── DeflaterSinkTest.kt
│       │           ├── DeflaterTest.kt
│       │           ├── InflateDeflateTest.kt
│       │           ├── InflaterSourceTest.kt
│       │           ├── InflaterTest.kt
│       │           └── NativeSystemFileSystemTest.kt
│       ├── nonAppleMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── ByteString.kt
│       │           └── SegmentedByteString.kt
│       ├── nonJsMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── internal/
│       │               └── ByteStringNonJs.kt
│       ├── nonJvmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── Buffer.kt
│       │           ├── BufferedSink.kt
│       │           ├── BufferedSource.kt
│       │           ├── ForwardingSource.kt
│       │           ├── HashingSink.kt
│       │           ├── HashingSource.kt
│       │           ├── NonJvmPlatform.kt
│       │           ├── Path.kt
│       │           ├── RealBufferedSink.kt
│       │           ├── RealBufferedSource.kt
│       │           ├── SegmentPool.kt
│       │           ├── Sink.kt
│       │           └── Timeout.kt
│       ├── nonJvmTest/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── NonJvmTesting.kt
│       ├── nonWasmTest/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── FakeFileSystemTest.kt
│       │           ├── ForwardingFileSystemTest.kt
│       │           └── UseTest.kt
│       ├── systemFileSystemMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── FileSystem.System.kt
│       ├── unixMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── UnixFileHandle.kt
│       │           └── UnixPosixVariant.kt
│       ├── wasmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── FileSystem.kt
│       │           └── WasmPlatform.kt
│       ├── zlibMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── Deflater.kt
│       │           ├── DeflaterSink.kt
│       │           ├── GzipSink.kt
│       │           ├── GzipSource.kt
│       │           ├── Inflater.kt
│       │           ├── InflaterSource.kt
│       │           ├── ZipFileSystem.kt
│       │           ├── ZlibOkio.kt
│       │           └── internal/
│       │               ├── -Zlib.kt
│       │               ├── CRC32.kt
│       │               ├── FixedLengthSource.kt
│       │               ├── ZipEntry.kt
│       │               └── ZipFiles.kt
│       └── zlibTest/
│           └── kotlin/
│               └── okio/
│                   ├── GzipKotlinTest.kt
│                   ├── GzipSinkTest.kt
│                   ├── GzipSourceTest.kt
│                   ├── ZipFileSystemGoTest.kt
│                   ├── ZipFileSystemTest.kt
│                   └── internal/
│                       ├── CRC32Test.kt
│                       └── DatePartsToEpochMillisTest.kt
├── okio-assetfilesystem/
│   ├── README.md
│   ├── api/
│   │   └── okio-assetfilesystem.api
│   ├── build.gradle.kts
│   └── src/
│       ├── androidTest/
│       │   ├── assets/
│       │   │   ├── dir/
│       │   │   │   └── nested.txt
│       │   │   ├── file.txt
│       │   │   └── moby10b.txt
│       │   └── kotlin/
│       │       └── okio/
│       │           └── assetfilesystem/
│       │               └── AssetFileSystemTest.kt
│       └── main/
│           └── kotlin/
│               └── okio/
│                   └── assetfilesystem/
│                       └── AssetFileSystem.kt
├── okio-bom/
│   └── build.gradle.kts
├── okio-fakefilesystem/
│   ├── README.md
│   ├── api/
│   │   └── okio-fakefilesystem.api
│   ├── build.gradle.kts
│   └── src/
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── fakefilesystem/
│       │               ├── FakeFileSystem.kt
│       │               └── FileMetadataCommon.kt
│       ├── jvmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── fakefilesystem/
│       │               └── FileMetadataJvm.kt
│       └── nonJvmMain/
│           └── kotlin/
│               └── okio/
│                   └── fakefilesystem/
│                       └── FileMetadataNonJvm.kt
├── okio-nodefilesystem/
│   ├── build.gradle.kts
│   └── src/
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── FileSink.kt
│       │           ├── FileSource.kt
│       │           ├── FsJs.kt
│       │           ├── NodeJsFileHandle.kt
│       │           └── NodeJsFileSystem.kt
│       └── commonTest/
│           └── kotlin/
│               └── okio/
│                   └── NodeJsFileSystemTest.kt
├── okio-testing-support/
│   ├── README.md
│   ├── build.gradle.kts
│   └── src/
│       ├── commonMain/
│       │   ├── kotlin/
│       │   │   └── okio/
│       │   │       ├── AbstractFileSystemTest.kt
│       │   │       ├── CloseBehavior.kt
│       │   │       ├── FakeClock.kt
│       │   │       ├── TestDirectory.kt
│       │   │       └── TestingCommon.kt
│       │   └── resources/
│       │       ├── go/
│       │       │   └── NOTICE
│       │       └── okio/
│       │           └── zipfilesystem/
│       │               ├── cannotReadZipWithSpanning.z01
│       │               └── cannotReadZipWithSpanning.z02
│       ├── jsMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── TestingJs.kt
│       ├── jvmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── TestExecutor.kt
│       │           └── TestingJvm.kt
│       ├── nativeMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── TestingNative.kt
│       ├── nonWasmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── TestingNonWasm.kt
│       ├── wasmJsMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── WasiEnvWasmJs.kt
│       ├── wasmMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           └── TestingWasm.kt
│       └── wasmWasiMain/
│           └── kotlin/
│               └── okio/
│                   ├── WasiClock.kt
│                   ├── WasiEnv.kt
│                   └── internal/
│                       └── preview1/
│                           ├── Clockid.kt
│                           ├── Preview1Clock.kt
│                           └── Preview1Env.kt
├── okio-wasifilesystem/
│   ├── README.md
│   ├── build.gradle.kts
│   └── src/
│       ├── wasmWasiMain/
│       │   └── kotlin/
│       │       └── okio/
│       │           ├── FileSink.kt
│       │           ├── FileSource.kt
│       │           ├── WasiFileHandle.kt
│       │           ├── WasiFileSystem.kt
│       │           └── internal/
│       │               ├── ErrnoException.kt
│       │               ├── Wasi.kt
│       │               └── preview1/
│       │                   ├── Errno.kt
│       │                   ├── Fdflags.kt
│       │                   ├── Filetype.kt
│       │                   ├── LookupFlags.kt
│       │                   ├── OFlags.kt
│       │                   ├── Preview1.kt
│       │                   └── Rights.kt
│       └── wasmWasiTest/
│           └── kotlin/
│               └── okio/
│                   ├── WasiFileSystemPreopensTest.kt
│                   ├── WasiFileSystemTest.kt
│                   └── WasiTest.kt
├── samples/
│   ├── build.gradle.kts
│   └── src/
│       ├── jvmMain/
│       │   ├── java/
│       │   │   └── okio/
│       │   │       └── samples/
│       │   │           ├── BitmapEncoder.java
│       │   │           ├── ByteChannelSink.java
│       │   │           ├── ByteChannelSource.java
│       │   │           ├── ExploreCharsets.java
│       │   │           ├── FileChannelSink.java
│       │   │           ├── FileChannelSource.java
│       │   │           ├── GoldenValue.java
│       │   │           ├── Hashing.java
│       │   │           ├── Interceptors.java
│       │   │           ├── Randoms.java
│       │   │           ├── ReadFileLineByLine.java
│       │   │           ├── ReadFileLineByLine.kt
│       │   │           ├── ReadJavaIoFileLineByLine.java
│       │   │           ├── SocksProxyServer.java
│       │   │           ├── SourceMarker.java
│       │   │           ├── WriteFile.java
│       │   │           └── WriteJavaIoFile.java
│       │   └── kotlin/
│       │       └── okio/
│       │           └── samples/
│       │               ├── BitmapEncoder.kt
│       │               ├── ExploreCharsets.kt
│       │               ├── GoldenValue.kt
│       │               ├── Hashing.kt
│       │               ├── ReadJavaIoFileLineByLine.kt
│       │               ├── SocksProxyServer.kt
│       │               ├── TeeSink.kt
│       │               ├── WriteFile.kt
│       │               └── WriteJavaIoFile.kt
│       └── jvmTest/
│           └── java/
│               └── okio/
│                   └── samples/
│                       ├── ChannelsTest.kt
│                       └── SourceMarkerTest.kt
└── settings.gradle.kts
Download .txt
SYMBOL INDEX (199 symbols across 29 files)

FILE: okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/AsyncTimeoutBenchmark.java
  class AsyncTimeoutBenchmark (line 37) | @Fork(1)
    method setup (line 52) | @Setup
    method enterExit (line 71) | @Benchmark

FILE: okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/BufferCursorSeekBenchmark.java
  class BufferCursorSeekBenchmark (line 35) | @Fork(1)
    method setup (line 48) | @Setup
    method seekBeginning (line 58) | @Benchmark
    method seekEnd (line 68) | @Benchmark
    method seekForward (line 78) | @Benchmark
    method seekBackward (line 89) | @Benchmark
    method main (line 100) | public static void main(String[] args) throws IOException, RunnerExcep...

FILE: okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/BufferPerformanceBenchmark.java
  class BufferPerformanceBenchmark (line 51) | @Fork(1)
    method threads1hot (line 98) | @Benchmark
    method threads2hot (line 104) | @Benchmark
    method threads4hot (line 110) | @Benchmark
    method threads8hot (line 116) | @Benchmark
    method threads16hot (line 122) | @Benchmark
    method threads32hot (line 128) | @Benchmark
    method thinkReadHot (line 134) | @Benchmark
    method thinkWriteCold (line 141) | @Benchmark
    method readWriteRecycle (line 148) | private void readWriteRecycle(HotBuffers buffers) throws IOException {
    method storeRequestResponseData (line 172) | @Setup(Level.Trial)
    method storeSourceData (line 180) | private byte[] storeSourceData(byte[] dest) throws IOException {
    method checkOrigin (line 188) | private void checkOrigin(File path) throws IOException {
    class ColdBuffers (line 213) | @State(Scope.Thread)
      method setupBench (line 216) | @Setup(Level.Trial)
      method lag (line 221) | @Setup(Level.Invocation)
    class HotBuffers (line 228) | @State(Scope.Thread)
      method setupBench (line 231) | @Setup(Level.Trial)
    class BufferSetup (line 238) | @State(Scope.Thread)
      method receive (line 242) | public BufferedSource receive(byte[] bytes) throws IOException {
      method transmit (line 246) | public BufferedSource transmit(byte[] bytes) throws IOException {
      method dispose (line 250) | @TearDown
    class BufferState (line 257) | public static class BufferState {
      method releaseBuffers (line 266) | public void releaseBuffers() throws IOException {
      method receive (line 277) | protected Buffer receive(byte[] bytes, int maxChunkSize) throws IOEx...
      method transmit (line 287) | protected BufferedSource transmit(byte[] bytes, int maxChunkSize) th...
      method writeChunked (line 292) | private BufferedSource writeChunked(Buffer buffer, byte[] bytes, fin...
    method write (line 309) | @Override public void write(Buffer source, long byteCount) throws EOFE...
    method flush (line 313) | @Override public void flush() {
    method timeout (line 317) | @Override public Timeout timeout() {
    method close (line 321) | @Override public void close() {
    method toString (line 325) | @Override public String toString() {

FILE: okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/BufferUtf8Benchmark.java
  class BufferUtf8Benchmark (line 40) | @Fork(1)
    method setup (line 100) | @Setup
    method writeUtf8 (line 119) | @Benchmark
    method readUtf8 (line 125) | @Benchmark
    method main (line 131) | public static void main(String[] args) throws IOException, RunnerExcep...

FILE: okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/GetByteBenchmark.java
  class GetByteBenchmark (line 35) | @Fork(1)
    method setup (line 47) | @Setup
    method getByteBeginning (line 55) | @Benchmark
    method getByteEnd (line 60) | @Benchmark
    method getByteMiddle (line 65) | @Benchmark
    method main (line 70) | public static void main(String[] args) throws IOException, RunnerExcep...

FILE: okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/HashFunctionBenchmark.java
  class HashFunctionBenchmark (line 35) | @Fork(1)
    method setup (line 53) | @Setup public void setup() throws NoSuchAlgorithmException {
    method jvm (line 58) | @Benchmark public void jvm() {
    method main (line 63) | public static void main(String[] args) throws IOException {

FILE: okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/IndexOfElementBenchmark.java
  class IndexOfElementBenchmark (line 36) | @Fork(1)
    method setup (line 49) | @Setup
    method indexOfByte (line 57) | @Benchmark
    method indexOfByteString (line 62) | @Benchmark
    method indexOfElement (line 67) | @Benchmark
    method main (line 72) | public static void main(String[] args) throws IOException, RunnerExcep...

FILE: okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/ReadByteStringBenchmark.java
  class ReadByteStringBenchmark (line 35) | @Fork(1)
    method setup (line 52) | @Setup
    method readByteString (line 57) | @Benchmark
    method readByteString_toByteArray (line 62) | @Benchmark
    method main (line 67) | public static void main(String[] args) throws IOException, RunnerExcep...

FILE: okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/SegmentedByteStringBenchmark.java
  class SegmentedByteStringBenchmark (line 36) | @Fork(1)
    method setup (line 52) | @Setup
    method substring (line 70) | @Benchmark
    method md5 (line 75) | @Benchmark
    method indexOfUnknown (line 80) | @Benchmark
    method lastIndexOfUnknown (line 85) | @Benchmark
    method indexOfEarly (line 90) | @Benchmark
    method lastIndexOfEarly (line 95) | @Benchmark
    method main (line 100) | public static void main(String[] args) throws IOException, RunnerExcep...

FILE: okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/SelectBenchmark.java
  class SelectBenchmark (line 40) | @Fork(1)
    method setup (line 72) | @Setup
    method select (line 88) | @Benchmark
    method main (line 97) | public static void main(String[] args) throws IOException, RunnerExcep...

FILE: okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/Utf8Benchmark.java
  class Utf8Benchmark (line 39) | @Fork(1)
    method setup (line 99) | @Setup
    method stringToBytesOkio (line 115) | @Benchmark
    method stringToBytesJava (line 120) | @Benchmark
    method bytesToStringOkio (line 125) | @Benchmark
    method bytesToStringJava (line 134) | @Benchmark
    method main (line 139) | public static void main(String[] args) throws IOException, RunnerExcep...

FILE: okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/WriteHexadecimalBenchmark.java
  class WriteHexadecimalBenchmark (line 37) | @Fork(1)
    method setup (line 50) | @Setup
    method teardown (line 55) | @TearDown(Level.Invocation)
    method writeHex (line 60) | @Benchmark
    method main (line 65) | public static void main(String[] args) throws IOException, RunnerExcep...

FILE: okio/src/linuxMain/headers/include/uapi/linux/stat.h
  type statx_timestamp (line 56) | struct statx_timestamp {
  type statx (line 99) | struct statx {

FILE: samples/src/jvmMain/java/okio/samples/BitmapEncoder.java
  class BitmapEncoder (line 24) | public final class BitmapEncoder {
    class Bitmap (line 25) | static final class Bitmap {
      method Bitmap (line 28) | Bitmap(int[][] pixels) {
      method width (line 32) | int width() {
      method height (line 36) | int height() {
      method red (line 40) | int red(int x, int y) {
      method green (line 44) | int green(int x, int y) {
      method blue (line 48) | int blue(int x, int y) {
    method generateGradient (line 57) | Bitmap generateGradient() {
    method encode (line 70) | void encode(Bitmap bitmap, FileSystem fileSystem, Path path) throws IO...
    method encode (line 77) | void encode(Bitmap bitmap, BufferedSink sink) throws IOException {
    method main (line 123) | public static void main(String[] args) throws Exception {

FILE: samples/src/jvmMain/java/okio/samples/ByteChannelSink.java
  class ByteChannelSink (line 32) | final class ByteChannelSink implements Sink {
    method ByteChannelSink (line 38) | ByteChannelSink(WritableByteChannel channel, Timeout timeout) {
    method write (line 43) | @Override public void write(Buffer source, long byteCount) throws IOEx...
    method flush (line 61) | @Override public void flush() {}
    method timeout (line 63) | @Override public Timeout timeout() {
    method close (line 67) | @Override public void close() throws IOException {

FILE: samples/src/jvmMain/java/okio/samples/ByteChannelSource.java
  class ByteChannelSource (line 32) | final class ByteChannelSource implements Source {
    method ByteChannelSource (line 38) | ByteChannelSource(ReadableByteChannel channel, Timeout timeout) {
    method read (line 43) | @Override public long read(Buffer sink, long byteCount) throws IOExcep...
    method timeout (line 63) | @Override public Timeout timeout() {
    method close (line 67) | @Override public void close() throws IOException {

FILE: samples/src/jvmMain/java/okio/samples/ExploreCharsets.java
  class ExploreCharsets (line 22) | public final class ExploreCharsets {
    method run (line 23) | public void run() throws Exception {
    method dumpStringData (line 28) | public void dumpStringData(String s) throws IOException {
    method main (line 37) | public static void main(String... args) throws Exception {

FILE: samples/src/jvmMain/java/okio/samples/FileChannelSink.java
  class FileChannelSink (line 29) | final class FileChannelSink implements Sink {
    method FileChannelSink (line 35) | FileChannelSink(FileChannel channel, Timeout timeout) throws IOExcepti...
    method write (line 42) | @Override public void write(Buffer source, long byteCount) throws IOEx...
    method flush (line 54) | @Override public void flush() throws IOException {
    method timeout (line 59) | @Override public Timeout timeout() {
    method close (line 63) | @Override public void close() throws IOException {

FILE: samples/src/jvmMain/java/okio/samples/FileChannelSource.java
  class FileChannelSource (line 29) | final class FileChannelSource implements Source {
    method FileChannelSource (line 35) | FileChannelSource(FileChannel channel, Timeout timeout) throws IOExcep...
    method read (line 42) | @Override public long read(Buffer sink, long byteCount) throws IOExcep...
    method timeout (line 51) | @Override public Timeout timeout() {
    method close (line 55) | @Override public void close() throws IOException {

FILE: samples/src/jvmMain/java/okio/samples/GoldenValue.java
  class GoldenValue (line 25) | public final class GoldenValue {
    method run (line 26) | public void run() throws Exception {
    method serialize (line 38) | private ByteString serialize(Object o) throws IOException {
    method deserialize (line 46) | private Object deserialize(ByteString byteString) throws IOException, ...
    class Point (line 56) | static final class Point implements Serializable {
      method Point (line 60) | Point(double x, double y) {
    method assertEquals (line 66) | private void assertEquals(Point a, Point b) {
    method main (line 70) | public static void main(String... args) throws Exception {

FILE: samples/src/jvmMain/java/okio/samples/Hashing.java
  class Hashing (line 30) | public final class Hashing {
    method run (line 31) | public void run() throws Exception {
    method readByteString (line 74) | public ByteString readByteString(Path path) throws IOException {
    method readBuffer (line 80) | public Buffer readBuffer(Path path) throws IOException {
    method main (line 88) | public static void main(String[] args) throws Exception {

FILE: samples/src/jvmMain/java/okio/samples/Interceptors.java
  class Interceptors (line 46) | public final class Interceptors {
    method run (line 47) | public void run() throws Exception {
    class InterceptingSource (line 85) | abstract class InterceptingSource extends ForwardingSource {
      method InterceptingSource (line 89) | InterceptingSource(Source source) {
      method read (line 93) | @Override
      method intercept (line 118) | protected abstract void intercept(byte[] data, int offset, int lengt...
    class InterceptingSink (line 122) | abstract class InterceptingSink extends ForwardingSink {
      method InterceptingSink (line 126) | InterceptingSink(Sink delegate) {
      method write (line 130) | @Override
      method intercept (line 155) | protected abstract void intercept(byte[] data, int offset, int lengt...
    method main (line 158) | public static void main(String... args) throws Exception {

FILE: samples/src/jvmMain/java/okio/samples/Randoms.java
  class Randoms (line 26) | public final class Randoms {
    method run (line 27) | public void run() throws IOException, InterruptedException {
    class RandomSource (line 33) | static final class RandomSource implements Source {
      method RandomSource (line 37) | RandomSource(Random random, long bytesLeft) {
      method read (line 42) | @Override public long read(Buffer sink, long byteCount) throws IOExc...
      method timeout (line 68) | @Override public Timeout timeout() {
      method close (line 72) | @Override public void close() throws IOException {
    method main (line 77) | public static void main(String... args) throws Exception {

FILE: samples/src/jvmMain/java/okio/samples/ReadFileLineByLine.java
  class ReadFileLineByLine (line 25) | public final class ReadFileLineByLine {
    method run (line 26) | public void run() throws Exception {
    method readLines (line 30) | public void readLines(Path path) throws IOException {
    method main (line 46) | public static void main(String... args) throws Exception {

FILE: samples/src/jvmMain/java/okio/samples/ReadJavaIoFileLineByLine.java
  class ReadJavaIoFileLineByLine (line 24) | public final class ReadJavaIoFileLineByLine {
    method run (line 25) | public void run() throws Exception {
    method readLines (line 29) | public void readLines(File file) throws IOException {
    method main (line 45) | public static void main(String... args) throws Exception {

FILE: samples/src/jvmMain/java/okio/samples/SocksProxyServer.java
  class SocksProxyServer (line 44) | public final class SocksProxyServer {
    method start (line 57) | public void start() throws IOException {
    method shutdown (line 62) | public void shutdown() throws IOException {
    method proxy (line 67) | public Proxy proxy() {
    method acceptSockets (line 72) | private void acceptSockets() {
    method handleSocket (line 88) | private void handleSocket(final Socket fromSocket) {
    method transfer (line 161) | private void transfer(Socket sourceSocket, Source source, Sink sink) {
    method closeQuietly (line 178) | private void closeQuietly(Closeable c) {
    method main (line 185) | public static void main(String[] args) throws IOException {

FILE: samples/src/jvmMain/java/okio/samples/SourceMarker.java
  class SourceMarker (line 37) | public final class SourceMarker {
    method SourceMarker (line 67) | public SourceMarker(Source source) {
    method source (line 74) | public BufferedSource source() {
    method mark (line 84) | public long mark(long readLimit) throws IOException {
    method reset (line 112) | public void reset(long userOffset) throws IOException {
    class MarkSource (line 129) | final class MarkSource extends ForwardingSource {
      method MarkSource (line 130) | MarkSource(Source source) {
      method read (line 134) | @Override public long read(Buffer sink, long byteCount) throws IOExc...
      method close (line 177) | @Override public void close() throws IOException {

FILE: samples/src/jvmMain/java/okio/samples/WriteFile.java
  class WriteFile (line 26) | public final class WriteFile {
    method run (line 27) | public void run() throws Exception {
    method writeEnv (line 31) | public void writeEnv(Path path) throws IOException {
    method main (line 45) | public static void main(String... args) throws Exception {

FILE: samples/src/jvmMain/java/okio/samples/WriteJavaIoFile.java
  class WriteJavaIoFile (line 25) | public final class WriteJavaIoFile {
    method run (line 26) | public void run() throws Exception {
    method writeEnv (line 30) | public void writeEnv(File file) throws IOException {
    method main (line 44) | public static void main(String... args) throws Exception {
Condensed preview — 404 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (3,346K chars).
[
  {
    "path": ".buildscript/prepare_mkdocs.sh",
    "chars": 430,
    "preview": "#!/bin/bash\n\n# The website is built using MkDocs with the Material theme.\n# https://squidfunk.github.io/mkdocs-material/"
  },
  {
    "path": ".buildscript/restore_v1_docs.sh",
    "chars": 750,
    "preview": "#!/bin/bash\n\n# Commit b3205fa199a19d6fbf13ee5c8e0c3d6d2b15b05f contains\n# Javadoc for Okio 1.x. Those should be present "
  },
  {
    "path": ".editorconfig",
    "chars": 242,
    "preview": "root = true\n\n[*]\ninsert_final_newline=true\nend_of_line=lf\ncharset=utf-8\nindent_size=2\ntrim_trailing_whitespace=true\n\n[*."
  },
  {
    "path": ".gitattributes",
    "chars": 52,
    "preview": "* text=auto eol=lf\n\n*.bat text eol=crlf\n*.jar binary"
  },
  {
    "path": ".github/renovate.json5",
    "chars": 657,
    "preview": "{\n  $schema: 'https://docs.renovatebot.com/renovate-schema.json',\n  extends: [\n    'config:recommended',\n  ],\n  ignorePr"
  },
  {
    "path": ".github/workflows/.java-version",
    "chars": 3,
    "preview": "25\n"
  },
  {
    "path": ".github/workflows/build.yml",
    "chars": 4965,
    "preview": "name: build\n\non:\n  pull_request: {}\n  workflow_dispatch: {}\n  push:\n    branches:\n      - 'master'\n    tags-ignore:\n    "
  },
  {
    "path": ".github/workflows/release.yaml",
    "chars": 784,
    "preview": "name: release\n\non:\n  push:\n    tags:\n      - '**'\n\nenv:\n  GRADLE_OPTS: \"-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon="
  },
  {
    "path": ".gitignore",
    "chars": 240,
    "preview": ".classpath\n.gradle\n.kotlin\n.project\n.settings\neclipsebin\n\nbin\ngen\nbuild\nout\nlib\nreports\n\n.idea\n*.iml\n*.ipr\n*.iws\nclasses"
  },
  {
    "path": "BUG-BOUNTY.md",
    "chars": 373,
    "preview": "Serious about security\n======================\n\nSquare recognizes the important contributions the security research commu"
  },
  {
    "path": "CHANGELOG.md",
    "chars": 44435,
    "preview": "Change Log\n==========\n\n## Unreleased\n\n * None yet.\n\n## Version 3.17.0\n\n_2026-03-11_\n\n * New: Adjust down the Kotlin stdl"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 1186,
    "preview": "Contributing\n============\n\nKeeping the project small and stable limits our ability to accept new contributors. We are no"
  },
  {
    "path": "LICENSE.txt",
    "chars": 11358,
    "preview": "\n                                 Apache License\n                           Version 2.0, January 2004\n                  "
  },
  {
    "path": "README.md",
    "chars": 1031,
    "preview": "Okio\n====\n\nSee the [project website][okio] for documentation and APIs.\n\nOkio is a library that complements `java.io` and"
  },
  {
    "path": "android-test/README.md",
    "chars": 1487,
    "preview": "Android Test\n============\n\nThis module runs Okio's test suite on a connected Android emulator or device. It requires the"
  },
  {
    "path": "android-test/build.gradle.kts",
    "chars": 2263,
    "preview": "import com.android.build.gradle.internal.lint.AndroidLintAnalysisTask\n\nplugins {\n  id(\"com.android.library\")\n}\n\nbuildscr"
  },
  {
    "path": "android-test/multidex-config.pro",
    "chars": 27,
    "preview": "-keep class okio.** { *; }\n"
  },
  {
    "path": "android-test/src/main/AndroidManifest.xml",
    "chars": 568,
    "preview": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n"
  },
  {
    "path": "android-test/src/main/res/values/strings.xml",
    "chars": 73,
    "preview": "<resources>\n  <string name=\"app_name\">android-test</string>\n</resources>\n"
  },
  {
    "path": "android-test/src/main/res/xml/network_security_config.xml",
    "chars": 159,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<network-security-config>\n  <base-config cleartextTrafficPermitted=\"false\">\n  </b"
  },
  {
    "path": "build-support/build.gradle.kts",
    "chars": 445,
    "preview": "plugins {\n  `kotlin-dsl`\n  `java-gradle-plugin`\n}\n\nrepositories {\n  mavenCentral()\n}\n\ndependencies {\n  add(\"compileOnly\""
  },
  {
    "path": "build-support/settings.gradle.kts",
    "chars": 136,
    "preview": "dependencyResolutionManagement {\n  versionCatalogs {\n    create(\"libs\") {\n      from(files(\"../gradle/libs.versions.toml"
  },
  {
    "path": "build-support/src/main/kotlin/BuildSupport.kt",
    "chars": 2475,
    "preview": "/*\n * Copyright (C) 2023 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "build-support/src/main/kotlin/bom.kt",
    "chars": 2540,
    "preview": "/*\n * Copyright (C) 2023 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "build-support/src/main/kotlin/jvm.kt",
    "chars": 723,
    "preview": "/*\n * Copyright (C) 2023 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "build-support/src/main/kotlin/kmp.kt",
    "chars": 1036,
    "preview": "/*\n * Copyright (C) 2023 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "build-support/src/main/kotlin/platforms.kt",
    "chars": 3292,
    "preview": "/*\n * Copyright (C) 2023 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "build.gradle.kts",
    "chars": 7538,
    "preview": "import aQute.bnd.gradle.BundleTaskExtension\nimport com.diffplug.gradle.spotless.SpotlessExtension\nimport com.vanniktech."
  },
  {
    "path": "docs/code_of_conduct.md",
    "chars": 5180,
    "preview": "Open Source Code of Conduct\n===========================\n\nAt Square, we are committed to contributing to the open source "
  },
  {
    "path": "docs/css/app.css",
    "chars": 1168,
    "preview": "@font-face {\n    font-family: cash-market;\n    src: url(\"https://cash-f.squarecdn.com/static/fonts/cash-market/v2/CashMa"
  },
  {
    "path": "docs/css/dokka-logo.css",
    "chars": 27,
    "preview": "#logo {\n  display: none;\n}\n"
  },
  {
    "path": "docs/file_system.md",
    "chars": 3522,
    "preview": "File System\n===========\n\nOkio's file system is designed to be easy, testable, multiplatform, and efficient.\n\n### Easy\n\nR"
  },
  {
    "path": "docs/index.md",
    "chars": 6207,
    "preview": "Okio\n====\n\nOkio is a library that complements `java.io` and `java.nio` to make it much\neasier to access, store, and proc"
  },
  {
    "path": "docs/java_io_recipes.md",
    "chars": 3157,
    "preview": "java.io Recipes\n===============\n\nThese recipes use Okio with `java.io.File` instead of Okio's own `Path` and `FileSystem"
  },
  {
    "path": "docs/multiplatform.md",
    "chars": 1509,
    "preview": "Multiplatform\n=============\n\nOkio is a [Kotlin Multiplatform][kotlin_multiplatform] project. We're still completing our "
  },
  {
    "path": "docs/recipes.md",
    "chars": 37803,
    "preview": "Recipes\n=======\n\nWe've written some recipes that demonstrate how to solve common problems with Okio. Read through\nthem t"
  },
  {
    "path": "docs/releasing.md",
    "chars": 1092,
    "preview": "Releasing\n=========\n\n1. Update `CHANGELOG.md`.\n\n2. Set versions:\n\n    ```\n    export RELEASE_VERSION=X.Y.Z\n    export NE"
  },
  {
    "path": "docs/security.md",
    "chars": 523,
    "preview": "Security Policy\n===============\n\n## Supported Versions\n\n| Version | Supported  |\n| ------- | ---------- |\n| 3.x     | ✅ "
  },
  {
    "path": "gradle/libs.versions.toml",
    "chars": 2165,
    "preview": "[versions]\nburst = \"2.10.2\"\njmh = \"1.37\"\nkotlin = \"2.2.21\"\n# Set to lower version than KGP version to maximize compatibi"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "chars": 252,
    "preview": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributi"
  },
  {
    "path": "gradle.properties",
    "chars": 545,
    "preview": "org.gradle.jvmargs='-Dfile.encoding=UTF-8'\n\nandroid.enableJetifier=false\nandroid.useAndroidX=true\nandroid.defaults.build"
  },
  {
    "path": "gradlew",
    "chars": 8631,
    "preview": "#!/bin/sh\n\n#\n# Copyright © 2015 the original authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\")"
  },
  {
    "path": "gradlew.bat",
    "chars": 2896,
    "preview": "@rem\r\n@rem Copyright 2015 the original author or authors.\r\n@rem\r\n@rem Licensed under the Apache License, Version 2.0 (th"
  },
  {
    "path": "mkdocs.yml",
    "chars": 2239,
    "preview": "site_name: Okio\nsite_url: https://square.github.io/okio\nrepo_name: Okio\nrepo_url: https://github.com/square/okio\nsite_de"
  },
  {
    "path": "okio/api/okio.api",
    "chars": 40538,
    "preview": "public final class okio/-DeflaterSinkExtensions {\n\tpublic static final fun deflate (Lokio/Sink;Ljava/util/zip/Deflater;)"
  },
  {
    "path": "okio/build.gradle.kts",
    "chars": 7564,
    "preview": "import aQute.bnd.gradle.BundleTaskExtension\nimport com.vanniktech.maven.publish.JavadocJar\nimport com.vanniktech.maven.p"
  },
  {
    "path": "okio/jvm/jmh/README.md",
    "chars": 222,
    "preview": "Okio Benchmarks\n===============\n\nThis module contains JMH microbenchmarks. Run benchmarks locally with Gradle:\n\n```\n$ ./"
  },
  {
    "path": "okio/jvm/jmh/build.gradle.kts",
    "chars": 121,
    "preview": "plugins {\n  kotlin(\"jvm\")\n  id(\"me.champeau.jmh\")\n}\n\njmh {\n}\n\ndependencies {\n  api(projects.okio)\n  api(libs.jmh.core)\n}"
  },
  {
    "path": "okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/AsyncTimeoutBenchmark.java",
    "chars": 2412,
    "preview": "/*\n * Copyright (C) 2025 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/BenchmarkUtils.kt",
    "chars": 1006,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/BufferCursorSeekBenchmark.java",
    "chars": 2753,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/BufferPerformanceBenchmark.java",
    "chars": 10083,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/BufferUtf8Benchmark.java",
    "chars": 5016,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/GetByteBenchmark.java",
    "chars": 2177,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/HashFunctionBenchmark.java",
    "chars": 2110,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/IndexOfElementBenchmark.java",
    "chars": 2369,
    "preview": "/*\n * Copyright (C) 2016 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/ReadByteStringBenchmark.java",
    "chars": 2253,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/SegmentedByteStringBenchmark.java",
    "chars": 3335,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/SelectBenchmark.java",
    "chars": 3962,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/Utf8Benchmark.java",
    "chars": 5501,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/WriteHexadecimalBenchmark.java",
    "chars": 2156,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/src/appleMain/kotlin/okio/ByteString.kt",
    "chars": 7102,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/appleMain/kotlin/okio/SegmentedByteString.kt",
    "chars": 3260,
    "preview": "/*\n * Copyright (C) 2015 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/appleNonMacosX64Main/kotlin/okio/NonMacosX64PosixVariant.kt",
    "chars": 1626,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/appleTest/kotlin/okio/AppleByteStringTest.kt",
    "chars": 1708,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/Base64.kt",
    "chars": 4609,
    "preview": "/*\n *  Licensed to the Apache Software Foundation (ASF) under one or more\n *  contributor license agreements.  See the N"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/Buffer.kt",
    "chars": 19167,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/BufferedSink.kt",
    "chars": 10997,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/BufferedSource.kt",
    "chars": 20902,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/ByteString.kt",
    "chars": 7381,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/CommonPlatform.kt",
    "chars": 1705,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/ExperimentalFileSystem.kt",
    "chars": 1049,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/FileHandle.kt",
    "chars": 13898,
    "preview": "/*\n * Copyright (C) 2021 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/FileMetadata.kt",
    "chars": 6711,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/FileSystem.kt",
    "chars": 18537,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/ForwardingFileSystem.kt",
    "chars": 8949,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/ForwardingSource.kt",
    "chars": 1217,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/HashingSink.kt",
    "chars": 2915,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/HashingSource.kt",
    "chars": 2981,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/Okio.kt",
    "chars": 2323,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/Options.kt",
    "chars": 8543,
    "preview": "/*\n * Copyright (C) 2016 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/Path.kt",
    "chars": 15414,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/PeekSource.kt",
    "chars": 2697,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/RealBufferedSink.kt",
    "chars": 2046,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/RealBufferedSource.kt",
    "chars": 2896,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/Segment.kt",
    "chars": 6324,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/SegmentPool.kt",
    "chars": 1206,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/SegmentedByteString.kt",
    "chars": 2559,
    "preview": "/*\n * Copyright (C) 2015 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/Sink.kt",
    "chars": 2539,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/Socket.kt",
    "chars": 1926,
    "preview": "/*\n * Copyright (C) 2025 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/Source.kt",
    "chars": 2976,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/Timeout.kt",
    "chars": 1908,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/TypedOptions.kt",
    "chars": 1404,
    "preview": "/*\n * Copyright (C) 2024 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/Utf8.kt",
    "chars": 16553,
    "preview": "/*\n * Copyright (C) 2017 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/Util.kt",
    "chars": 6334,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/internal/-Utf8.kt",
    "chars": 1919,
    "preview": "// ktlint-disable filename\n/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (t"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/internal/Buffer.kt",
    "chars": 50603,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/internal/BufferedSource.kt",
    "chars": 1001,
    "preview": "/*\n * Copyright (C) 2024 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/internal/ByteString.kt",
    "chars": 9779,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/internal/FileSystem.kt",
    "chars": 4523,
    "preview": "/*\n * Copyright (C) 2021 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/internal/Path.kt",
    "chars": 12143,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/internal/RealBufferedSink.kt",
    "chars": 6043,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/internal/RealBufferedSource.kt",
    "chars": 13575,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonMain/kotlin/okio/internal/SegmentedByteString.kt",
    "chars": 8078,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/BufferCommonTest.kt",
    "chars": 3013,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/BufferedSinkFactory.kt",
    "chars": 923,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/BufferedSourceFactory.kt",
    "chars": 3301,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/ByteStringFactory.kt",
    "chars": 1745,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/ByteStringMoreTests.kt",
    "chars": 918,
    "preview": "/*\n * Copyright (C) 2022 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/ByteStringTest.kt",
    "chars": 24428,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/CommonBufferTest.kt",
    "chars": 14143,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/CommonBufferedSinkTest.kt",
    "chars": 11690,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/CommonBufferedSourceTest.kt",
    "chars": 38166,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/CommonOkioKotlinTest.kt",
    "chars": 1200,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/CommonOptionsTest.kt",
    "chars": 13213,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/CommonRealBufferedSinkTest.kt",
    "chars": 5988,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/CommonRealBufferedSourceTest.kt",
    "chars": 5272,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/ForwardingSourceTest.kt",
    "chars": 1540,
    "preview": "/*\n * Copyright (C) 2022 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/HashingSinkTest.kt",
    "chars": 3679,
    "preview": "/*\n * Copyright (C) 2016 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/HashingSourceTest.kt",
    "chars": 4428,
    "preview": "/*\n * Copyright (C) 2016 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/HashingTest.kt",
    "chars": 4751,
    "preview": "/*\n * Copyright 2014 Square Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/MockSink.kt",
    "chars": 1663,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/OkioTesting.kt",
    "chars": 3021,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/PathTest.kt",
    "chars": 30367,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/TypedOptionsTest.kt",
    "chars": 3054,
    "preview": "/*\n * Copyright (C) 2024 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/UnsafeCursorTest.kt",
    "chars": 2376,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/commonTest/kotlin/okio/Utf8KotlinTest.kt",
    "chars": 6877,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/hashFunctions/kotlin/okio/internal/HashFunction.kt",
    "chars": 831,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/src/hashFunctions/kotlin/okio/internal/Hmac.kt",
    "chars": 2195,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/hashFunctions/kotlin/okio/internal/Md5.kt",
    "chars": 6101,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/hashFunctions/kotlin/okio/internal/Sha1.kt",
    "chars": 5397,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/hashFunctions/kotlin/okio/internal/Sha256.kt",
    "chars": 7029,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/hashFunctions/kotlin/okio/internal/Sha512.kt",
    "chars": 9253,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jsMain/kotlin/okio/FileSystem.kt",
    "chars": 3150,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jsMain/kotlin/okio/JsPlatform.kt",
    "chars": 1515,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jsMain/kotlin/okio/internal/ByteStringJs.kt",
    "chars": 2117,
    "preview": "/*\n * Copyright (C) 2025 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/-DeprecatedOkio.kt",
    "chars": 4049,
    "preview": "// ktlint-disable filename\n/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (t"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/-DeprecatedUtf8.kt",
    "chars": 1309,
    "preview": "// ktlint-disable filename\n/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (t"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/-JvmPlatform.kt",
    "chars": 1814,
    "preview": "// ktlint-disable filename\n/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (t"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/AsyncTimeout.kt",
    "chars": 16882,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/Buffer.kt",
    "chars": 20240,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/BufferedSink.kt",
    "chars": 3195,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/BufferedSource.kt",
    "chars": 4714,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/ByteString.kt",
    "chars": 11593,
    "preview": "/*\n * Copyright 2014 Square Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/CipherSink.kt",
    "chars": 4091,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/CipherSource.kt",
    "chars": 3302,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/DeflaterSink.kt",
    "chars": 4239,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/DeprecatedUpgrade.kt",
    "chars": 710,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/FileSystem.System.kt",
    "chars": 447,
    "preview": "@file:JvmName(\"SystemFileSystem\")\n\npackage okio\n\n/*\n * JVM and native platforms do offer a [SYSTEM] [FileSystem], howeve"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/FileSystem.kt",
    "chars": 6381,
    "preview": "/*\n * Copyright (C) 2021 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/ForwardingSink.kt",
    "chars": 1538,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/ForwardingSource.kt",
    "chars": 1407,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/ForwardingTimeout.kt",
    "chars": 1981,
    "preview": "/*\n * Copyright (C) 2015 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/HashingSink.kt",
    "chars": 5089,
    "preview": "/*\n * Copyright (C) 2016 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/HashingSource.kt",
    "chars": 5420,
    "preview": "/*\n * Copyright (C) 2016 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/InflaterSource.kt",
    "chars": 4417,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/JvmFileHandle.kt",
    "chars": 2053,
    "preview": "/*\n * Copyright (C) 2021 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/JvmOkio.kt",
    "chars": 7716,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/JvmSystemFileSystem.kt",
    "chars": 4996,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/NioFileSystemFileHandle.kt",
    "chars": 2138,
    "preview": "/*\n * Copyright (C) 2023 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/NioFileSystemWrappingFileSystem.kt",
    "chars": 6546,
    "preview": "/*\n * Copyright (C) 2023 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/NioSystemFileSystem.kt",
    "chars": 3068,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/Path.kt",
    "chars": 3947,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/Pipe.kt",
    "chars": 8254,
    "preview": "/*\n * Copyright (C) 2016 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/RealBufferedSink.kt",
    "chars": 5210,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/RealBufferedSource.kt",
    "chars": 8177,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/SegmentPool.kt",
    "chars": 4994,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/SegmentedByteString.kt",
    "chars": 4431,
    "preview": "/*\n * Copyright (C) 2015 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/Sink.kt",
    "chars": 979,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/Throttler.kt",
    "chars": 5974,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/Timeout.kt",
    "chars": 12025,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/internal/-Atomic.kt",
    "chars": 1068,
    "preview": "// ktlint-disable filename\n/*\n * Copyright (C) 2025 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (t"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/internal/-JavaIo.kt",
    "chars": 1995,
    "preview": "// ktlint-disable filename\n/*\n * Copyright (C) 2025 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (t"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/internal/-ZlibJvm.kt",
    "chars": 1203,
    "preview": "// ktlint-disable filename\n/*\n * Copyright (C) 2024 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (t"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/internal/DefaultSocket.kt",
    "chars": 5499,
    "preview": "/*\n * Copyright (C) 2025 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/internal/PipeSocket.kt",
    "chars": 963,
    "preview": "/*\n * Copyright (C) 2025 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmMain/kotlin/okio/internal/ResourceFileSystem.kt",
    "chars": 7546,
    "preview": "/*\n * Copyright (C) 2021 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/AsyncSocket.kt",
    "chars": 2290,
    "preview": "/*\n * Copyright (C) 2025 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/AsyncTimeoutTest.kt",
    "chars": 12502,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/AwaitSignalTest.kt",
    "chars": 5713,
    "preview": "/*\n * Copyright (C) 2023 Block Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/BufferCursorKotlinTest.kt",
    "chars": 3520,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/BufferCursorTest.kt",
    "chars": 13170,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/BufferFactory.kt",
    "chars": 1727,
    "preview": "/*\n * Copyright (C) 2019 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/BufferKotlinTest.kt",
    "chars": 2872,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/BufferTest.kt",
    "chars": 19749,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/BufferedSinkJavaTest.kt",
    "chars": 6860,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/BufferedSinkTest.kt",
    "chars": 10590,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/BufferedSourceJavaTest.kt",
    "chars": 6841,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/BufferedSourceTest.kt",
    "chars": 53011,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/ByteStringJavaTest.kt",
    "chars": 8297,
    "preview": "/*\n * Copyright 2014 Square Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/ByteStringKotlinTest.kt",
    "chars": 2294,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/CipherAlgorithm.kt",
    "chars": 2084,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/CipherFactory.kt",
    "chars": 1092,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/CipherSinkTest.kt",
    "chars": 6416,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/CipherSourceTest.kt",
    "chars": 6628,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/DeflateKotlinTest.kt",
    "chars": 1678,
    "preview": "/*\n * Copyright (C) 2018 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/DeflaterSinkTest.kt",
    "chars": 5671,
    "preview": "/*\n * Copyright (C) 2014 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/FileHandleFileSystemTest.kt",
    "chars": 3562,
    "preview": "/*\n * Copyright (C) 2021 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/FileLeakTest.kt",
    "chars": 5060,
    "preview": "/*\n * Copyright (C) 2023 Square, Inc. and others.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  },
  {
    "path": "okio/src/jvmTest/kotlin/okio/FileSystemJavaTest.kt",
    "chars": 4662,
    "preview": "/*\n * Copyright (C) 2020 Square, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
  }
]

// ... and 204 more files (download for full content)

About this extraction

This page contains the full source code of the square/okio GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 404 files (3.1 MB), approximately 824.9k tokens, and a symbol index with 199 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!