(ctx: Context)
| 15 | }; |
| 16 | |
| 17 | pub 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 |
| 51 | fn io_read_file<'gc>(state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> { |
no test coverage detected