scoop:scoop.platform:0.1.0
src/fs/native_handle.scoop
Selected production source · src/fs/native_handle.scoop
1
package scoop.platform.fs3
import scoop.platform.system.*4
import scoop.platform.native.NativeFileMetadata6
@CLayout7
internal struct NativeFileHandle(val value: ULong)9
@CLayout10
internal 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 handle15
}16
}18
@CLayout19
internal 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 value24
}25
}27
@CLayout28
internal struct NativeFileMetadataResult(val data: NativeFileMetadata, val error: Int)30
@Extern(name = "scoop_platform_handle_read")31
internal fun nativeFileRead(32
handle: NativeFileHandle,33
data: Ptr<Byte>,34
count: Long35
): NativeFileResult37
@Extern(name = "scoop_platform_handle_write")38
internal fun nativeFileWrite(39
handle: NativeFileHandle,40
data: Ptr<Byte>,41
count: Long42
): NativeFileResult44
@Extern(name = "scoop_platform_handle_close")45
internal fun nativeFileClose(handle: NativeFileHandle): NativeFileResult47
@Extern(name = "scoop_platform_handle_duplicate")48
internal fun nativeFileDuplicate(handle: NativeFileHandle): NativeFileOpened50
@Extern(name = "scoop_platform_handle_standard")51
internal fun nativeFileStandard(stream: Int): NativeFileOpened53
@Extern(name = "scoop_platform_handle_metadata")54
internal fun nativeFileMetadata(handle: NativeFileHandle): NativeFileMetadataResult