feat: commit plugin init

This commit is contained in:
mrxiaozhuox committed 2022-08-02 15:22:48 +08:00
1 parent 7609406bcd
commit f915a38ad4
3 files changed
+39 -7

No files matched your search

+6 -1
View File
@@ -1,5 +1,5 @@
use std::{
fs::{create_dir, create_dir_all},
fs::{create_dir, create_dir_all, remove_dir_all},
path::PathBuf, io::{Read, Write},
};
@@ -34,6 +34,11 @@ impl UserData for PluginFileSystem {
}
Ok(true)
});
methods.add_function("remove_dir", |_, path: String| {
let path = PathBuf::from(path);
let r = remove_dir_all(path);
Ok(r.is_ok())
});
methods.add_function("file_get_content", |_, path: String| {
let path = PathBuf::from(path);
let mut file = std::fs::File::open(path)?;