-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28fd2db
commit 8de9c0f
Showing
31 changed files
with
573 additions
and
644 deletions.
There are no files selected for viewing
58 changes: 0 additions & 58 deletions
58
wasi-emscripten-fs/src/linuxArm64Main/kotlin/PlatformFileSystemOperations.linuxArm64.kt
This file was deleted.
Oops, something went wrong.
60 changes: 0 additions & 60 deletions
60
wasi-emscripten-fs/src/linuxArm64Main/kotlin/posix/LinuxArm64StatFd.kt
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
wasi-emscripten-fs/src/linuxArm64Main/kotlin/posix/LinuxStat.linuxArm64.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2024, the wasm-sqlite-open-helper project authors and contributors. Please see the AUTHORS file | ||
* for details. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package ru.pixnews.wasm.sqlite.open.helper.host.filesystem.posix | ||
|
||
import arrow.core.Either | ||
import arrow.core.left | ||
import arrow.core.right | ||
import kotlinx.cinterop.alloc | ||
import kotlinx.cinterop.memScoped | ||
import kotlinx.cinterop.ptr | ||
import platform.posix.errno | ||
import platform.posix.stat | ||
import ru.pixnews.wasm.sqlite.open.helper.host.filesystem.op.stat.FileModeType | ||
import ru.pixnews.wasm.sqlite.open.helper.host.filesystem.op.stat.StructStat | ||
import ru.pixnews.wasm.sqlite.open.helper.host.filesystem.posix.ext.toStructTimespec | ||
import ru.pixnews.wasm.sqlite.open.helper.host.platform.linux.fstatat | ||
|
||
internal actual fun platformFstatat( | ||
dirfd: Int, | ||
path: String, | ||
statFlags: Int, | ||
): Either<Int, StructStat> = memScoped { | ||
val statBuf: stat = alloc() | ||
val exitCode = fstatat( | ||
dirfd, | ||
path, | ||
statBuf.ptr, | ||
statFlags, | ||
) | ||
return if (exitCode == 0) { | ||
statBuf.toStructStat().right() | ||
} else { | ||
errno.left() | ||
} | ||
} | ||
|
||
internal fun stat.toStructStat(): StructStat = StructStat( | ||
deviceId = st_dev, | ||
inode = st_ino, | ||
mode = FileModeType.fromLinuxModeType(st_mode), | ||
links = st_nlink.toULong(), | ||
usedId = st_uid.toULong(), | ||
groupId = st_gid.toULong(), | ||
specialFileDeviceId = st_rdev, | ||
size = st_size.toULong(), | ||
blockSize = st_blksize.toULong(), | ||
blocks = st_blocks.toULong(), | ||
accessTime = st_atim.toStructTimespec(), | ||
modificationTime = st_mtim.toStructTimespec(), | ||
changeStatusTime = st_ctim.toStructTimespec(), | ||
) |
31 changes: 31 additions & 0 deletions
31
wasi-emscripten-fs/src/linuxArm64Main/kotlin/posix/LinuxStatFd.linuxArm64.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2024, the wasm-sqlite-open-helper project authors and contributors. Please see the AUTHORS file | ||
* for details. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package ru.pixnews.wasm.sqlite.open.helper.host.filesystem.posix | ||
|
||
import arrow.core.Either | ||
import arrow.core.left | ||
import arrow.core.right | ||
import kotlinx.cinterop.alloc | ||
import kotlinx.cinterop.memScoped | ||
import kotlinx.cinterop.ptr | ||
import platform.posix.errno | ||
import platform.posix.fstat | ||
import platform.posix.stat | ||
import ru.pixnews.wasm.sqlite.open.helper.host.filesystem.op.stat.StructStat | ||
|
||
internal actual fun platformFstatFd(fd: Int): Either<Int, StructStat> = memScoped { | ||
val statBuf: stat = alloc() | ||
val exitCode = fstat( | ||
fd, | ||
statBuf.ptr, | ||
) | ||
return if (exitCode == 0) { | ||
statBuf.toStructStat().right() | ||
} else { | ||
errno.left() | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
wasi-emscripten-fs/src/linuxArm64Main/kotlin/posix/SyscallOpenat2.linuxArm64.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.