MCPcopy Create free account
hub / github.com/aiscriptdev/aiscript / io_remove_dir

Function io_remove_dir

aiscript-vm/src/stdlib/io.rs:193–208  ·  view source on GitHub ↗
(
    _state: &mut State<'gc>,
    args: Vec<Value<'gc>>,
)

Source from the content-addressed store, hash-verified

191}
192
193fn io_remove_dir<'gc>(
194 _state: &mut State<'gc>,
195 args: Vec<Value<'gc>>,
196) -> Result<Value<'gc>, VmError> {
197 let path = string_arg!(args, 0, "remove_dir")?.to_string();
198 let recursive = args.get(1).map(|v| v.as_boolean()).unwrap_or(false);
199
200 if recursive {
201 fs::remove_dir_all(&path)
202 } else {
203 fs::remove_dir(&path)
204 }
205 .map_err(|e| VmError::RuntimeError(format!("Failed to remove directory '{}': {}", path, e)))?;
206
207 Ok(Value::Boolean(true))
208}
209
210fn io_rename<'gc>(_state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> {
211 let from = string_arg!(args, 0, "rename")?.to_string();

Callers

nothing calls this directly

Calls 3

RuntimeErrorClass · 0.85
as_booleanMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected