MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / create_io_module

Function create_io_module

aiscript-vm/src/stdlib/io.rs:17–48  ·  view source on GitHub ↗
(ctx: Context)

Source from the content-addressed store, hash-verified

15};
16
17pub fn create_io_module(ctx: Context) -> ModuleKind {
18 let name = ctx.intern_static("std.io");
19
20 let exports = [
21 // File reading/writing
22 ("read_file", Value::NativeFunction(NativeFn(io_read_file))),
23 // ("read_bytes", Value::NativeFunction(NativeFn(io_read_bytes))),
24 ("read_lines", Value::NativeFunction(NativeFn(io_read_lines))),
25 ("write_file", Value::NativeFunction(NativeFn(io_write_file))),
26 (
27 "append_file",
28 Value::NativeFunction(NativeFn(io_append_file)),
29 ),
30 // Standard IO
31 ("input", Value::NativeFunction(NativeFn(io_input))),
32 // File/directory operations
33 ("exists", Value::NativeFunction(NativeFn(io_exists))),
34 ("is_file", Value::NativeFunction(NativeFn(io_is_file))),
35 ("is_dir", Value::NativeFunction(NativeFn(io_is_dir))),
36 ("create_dir", Value::NativeFunction(NativeFn(io_create_dir))),
37 (
38 "remove_file",
39 Value::NativeFunction(NativeFn(io_remove_file)),
40 ),
41 ("remove_dir", Value::NativeFunction(NativeFn(io_remove_dir))),
42 ("rename", Value::NativeFunction(NativeFn(io_rename))),
43 ]
44 .into_iter()
45 .map(|(name, f)| (ctx.intern_static(name), f))
46 .collect();
47 ModuleKind::Native { name, exports }
48}
49
50// File reading functions
51fn io_read_file<'gc>(state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> {

Callers 1

init_stdlibMethod · 0.85

Calls 2

NativeFnClass · 0.85
intern_staticMethod · 0.45

Tested by

no test coverage detected