Zhang Zihan
05/12/2024, 5:19 PMRawSource.readAtMostTo(sink, byteCount)
read at most 8192 bytes at a time? How to read more at once?Florian Levis
05/17/2024, 9:12 PMpublic fun Source.readAtMostTo(sink: UByteArray, startIndex: Int = 0, endIndex: Int = sink.size): Int
I know unsigned types are still flagged as experimental
Right now I'm using the function .toUByteArray()
on the sink after using it; so it's not a blocking issue.
Thanks.
Regards.Florian Levis
05/30/2024, 4:01 PMEdoardo Luppi
06/10/2024, 10:06 AMEdoardo Luppi
06/10/2024, 3:42 PMSomeApi
! See the SomeApi_instance = new SomeApi();
bit
function FunctionCallBenchmark() {
this.re_1 = 0;
}
protoOf(FunctionCallBenchmark).se = function (bh) {
// Inline function 'kotlinx.benchmark.Blackhole.consume' call
var i = freeFunction(0);
bh.pe(i);
};
protoOf(FunctionCallBenchmark).te = function (bh) {
// Inline function 'kotlinx.benchmark.Blackhole.consume' call
var i = SomeApi_instance.callOnObject(0);
bh.pe(i);
};
function SomeApi() {
}
protoOf(SomeApi).callOnObject = function (x) {
return imul(x, 2);
};
var SomeApi_instance;
function SomeApi_getInstance() {
return SomeApi_instance;
}
function freeFunction(x) {
return imul(x, 2);
}
//region block: init
SomeApi_instance = new SomeApi();
//endregion
//region block: exports
function $jsExportAll$(_) {
var $org = _.org || (_.org = {});
var $org$example = $org.example || ($org.example = {});
defineProp($org$example, 'SomeApi', SomeApi_getInstance);
$org$example.freeFunction = freeFunction;
}
$jsExportAll$(_);
_.$jsExportAll$ = $jsExportAll$;
_.$_$ = _.$_$ || {};
_.$_$.a = FunctionCallBenchmark;
//endregion
return _;
Colin White
07/18/2024, 6:37 PMkotlinx.io.Source
into an okio.Sink
? I’m currently creating an intermediate ByteArray
to write the bytes to then writing those bytes to the okio.Sink
, but I’m wondering if there’s a better wayFrancis Mariano
08/05/2024, 8:31 PMColton Idle
08/07/2024, 4:48 PMFilipp Zhinkin
08/12/2024, 9:56 PMFilipp Zhinkin
08/12/2024, 9:56 PMFilipp Zhinkin
08/12/2024, 9:56 PMGary Peck
08/17/2024, 9:35 AMJavier
10/09/2024, 9:24 PMkotlinx-io
is there any easy way to read a file from the resources
directory?alexandre mommers
10/11/2024, 1:20 PMMorten Minke
11/25/2024, 7:39 PMreadInto
method which is a suspend method (which makes sense with io operations). I want convert this FileKit specific PlatformInputStream into a generic kotlinx.io (Raw)Source to further use in my application. However, the kotlinx.io RawSource has a method, override fun readAtMostTo
, which I need to implement for this, but this method is not a suspend function.
Because this is a MPP and both FileKit and kotlinx.io are also MPP I think I should be able to make this work in common code, but I fail because the readInto method is not a suspend function but I need a coroutine context to call the readAtMostTo and wait for the result to return. In jvm I would be able to use runBlocking to call and wait for the result, but this is not possible in MPP common code. I really thought about different solutions but I cannot find a good solution for this. Does anybody have an idea?
For simplicity here is some pseudo code showing what I try to achieve:
class PlatformInputStreamSource(
private val platformInputStream: PlatformInputStream
) : RawSource {
override fun readAtMostTo(sink: Buffer, byteCount: Long): Long {
...
<< Here i need to start a coroutine context and wait for the numberOfBytesCopied
val numberOfBytesCopied = platformInputStream.readInto(buffer, byteCount, bufferSize))
...
<< This non suspend function needs to return the number of bytes copied and therefor has to wait for the result from the readInto function.
return numberOfBytesCopied.toLong()
}
}
suresh
11/25/2024, 9:49 PMhfhbd
11/26/2024, 8:59 PMmyRawSource.buffered().buffered().buffered()
creates a new RealSource each time? Shouldn't be there an extension on Source.buffered() = this
?hfhbd
12/04/2024, 12:49 PMChris Lee
12/05/2024, 7:15 PMedenman
12/06/2024, 7:02 PMMark
12/09/2024, 5:37 AMTóth István Zoltán
12/26/2024, 6:10 AMfun Path.copy(target: Path, override: Boolean = false) {
check(target.exists() && ! override) { "file $target already exists" }
SystemFileSystem.sink(target, append = false).buffered().use { sink ->
SystemFileSystem.source(this).buffered().use { source ->
source.transferTo(sink)
}
}
}
Rob Elliot
03/14/2025, 10:13 AMkotlinx.io.asSource
returns a RawSource
, which is not a Source
.
Have you considered renaming it to kotlinx.io.asRawSource
, and making kotlinx.io.asSource
syntactic sugar for .asRawSource().buffered()
?Tóth István Zoltán
03/20/2025, 5:55 AMatomicMove
in <http://kotlinx.io|kotlinx.io>
does not support overwriting existing files. Any advices how to achieve this?
The problem with delete
+ atomicMove
is that there exists a moment where the original file is deleted but the move did not happen yet.edenman
04/03/2025, 3:51 PMSource
is all syncRTAkland
04/05/2025, 10:57 AMhfhbd
04/09/2025, 10:25 AMrawSource.readAtMostTo()
, but this api requires a Buffer
, not a RawSink
that can be ignored by an discardingSink
. (I can use discardingSink().buffered().buffer
though, but it is an internal api.)RTAkland
04/18/2025, 7:00 AMkevin.cianfarini
04/25/2025, 8:04 PMdummy: Any?
parameter which is always null? https://github.com/Kotlin/kotlinx-io/blob/master/bytestring/common/src/ByteString.kt#L81hfhbd
05/08/2025, 6:41 AM