RandomAccessStorage

actual class RandomAccessStorage(path: String)

Android random-access file: identical to the JVM actual (java.io is available on Android).

expect class RandomAccessStorage(path: String)

Random-access file handle. This is the one thing a torrent client needs from the filesystem that has no common-stdlib equivalent: reading and writing at an arbitrary byte offset. kotlinx-io's FileSystem is stream-oriented, so this is a small platform expect/actual (RandomAccessFile on JVM/Android, POSIX fseeko/fread/fwrite on Apple).

libtorrent fills the same seam with pread and pwrite (mmap_storage.cpp).

actual class RandomAccessStorage(path: String)

Apple (iOS/macOS) random-access file via POSIX stdio with positional seeks.

actual class RandomAccessStorage(path: String)

JVM/desktop random-access file via RandomAccessFile (seek + positional read/write).

Constructors

Link copied to clipboard
actual constructor(path: String)
expect constructor(path: String)
actual constructor(path: String)
actual constructor(path: String)

Functions

Link copied to clipboard
actual fun close()

Close the handle.

expect fun close()

Close the handle.

actual fun close()

Close the handle.

actual fun close()

Close the handle.

Link copied to clipboard
actual fun flush()

Flush buffered writes to durable storage.

expect fun flush()

Flush buffered writes to durable storage.

actual fun flush()

Flush buffered writes to durable storage.

actual fun flush()

Flush buffered writes to durable storage.

Link copied to clipboard
actual fun length(): Long

Current file length in bytes.

expect fun length(): Long

Current file length in bytes.

actual fun length(): Long

Current file length in bytes.

actual fun length(): Long

Current file length in bytes.

Link copied to clipboard
actual fun readAt(offset: Long, into: ByteArray, intoOffset: Int, length: Int): Int

Read up to length bytes at file offset into into; returns bytes read (may be < length at EOF).

expect fun readAt(offset: Long, into: ByteArray, intoOffset: Int, length: Int): Int

Read up to length bytes at file offset into into; returns bytes read (may be < length at EOF).

actual fun readAt(offset: Long, into: ByteArray, intoOffset: Int, length: Int): Int

Read up to length bytes at file offset into into; returns bytes read (may be < length at EOF).

actual fun readAt(offset: Long, into: ByteArray, intoOffset: Int, length: Int): Int

Read up to length bytes at file offset into into; returns bytes read (may be < length at EOF).

Link copied to clipboard
actual fun writeAt(offset: Long, from: ByteArray, fromOffset: Int, length: Int)

Write length bytes from from at file offset, extending the file if needed.

expect fun writeAt(offset: Long, from: ByteArray, fromOffset: Int, length: Int)

Write length bytes from from at file offset, extending the file if needed.

actual fun writeAt(offset: Long, from: ByteArray, fromOffset: Int, length: Int)

Write length bytes from from at file offset, extending the file if needed.

actual fun writeAt(offset: Long, from: ByteArray, fromOffset: Int, length: Int)

Write length bytes from from at file offset, extending the file if needed.