Scoop API

scoop:scoop.platform:0.1.0

src/fs/native_handle.scoop

Selected production source · src/fs/native_handle.scoop

1package scoop.platform.fs
3import scoop.platform.system.*
4import scoop.platform.native.NativeFileMetadata
6@CLayout
7internal struct NativeFileHandle(val value: ULong)
9@CLayout
10internal struct NativeFileOpened(val handle: NativeFileHandle, val error: Int) {
11 fun checked(operation: String, context: OsString? = None): NativeFileHandle {
12 if (error != 0)
13 failOperatingSystem(operation, error, context)
14 return handle
15 }
18@CLayout
19internal struct NativeFileResult(val value: Long, val error: Int) {
20 fun checked(operation: String, context: OsString? = None): Long {
21 if (error != 0)
22 failOperatingSystem(operation, error, context)
23 return value
24 }
27@CLayout
28internal struct NativeFileMetadataResult(val data: NativeFileMetadata, val error: Int)
30@Extern(name = "scoop_platform_handle_read")
31internal fun nativeFileRead(
32 handle: NativeFileHandle,
33 data: Ptr<Byte>,
34 count: Long
35): NativeFileResult
37@Extern(name = "scoop_platform_handle_write")
38internal fun nativeFileWrite(
39 handle: NativeFileHandle,
40 data: Ptr<Byte>,
41 count: Long
42): NativeFileResult
44@Extern(name = "scoop_platform_handle_close")
45internal fun nativeFileClose(handle: NativeFileHandle): NativeFileResult
47@Extern(name = "scoop_platform_handle_duplicate")
48internal fun nativeFileDuplicate(handle: NativeFileHandle): NativeFileOpened
50@Extern(name = "scoop_platform_handle_standard")
51internal fun nativeFileStandard(stream: Int): NativeFileOpened
53@Extern(name = "scoop_platform_handle_metadata")
54internal fun nativeFileMetadata(handle: NativeFileHandle): NativeFileMetadataResult