Skip to content

Commit

Permalink
feat: add mime() method to the file api
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Oct 14, 2023
1 parent 29e3136 commit 0b09018
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugin/src/bindings/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ impl Files {
Ok(shared::permissions(me.meta().permissions()))
});

reg.add_function("mime", |_, me: AnyUserData| {
let manager = me.named_user_value::<UserDataRef<core::manager::Manager>>("manager")?;
let file = me.borrow::<core::files::File>()?;
Ok(manager.mimetype.get(file.url()).cloned())
});

reg.add_function("prefix", |_, me: AnyUserData| {
let folder = me.named_user_value::<UserDataRef<core::manager::Folder>>("folder")?;
if !folder.cwd.is_search() {
Expand Down

0 comments on commit 0b09018

Please sign in to comment.