mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
draft file type router
This commit is contained in:
parent
9e1fb9c5ca
commit
0574ab81fd
1 changed files with 47 additions and 10 deletions
|
|
@ -4,25 +4,62 @@ use std::rc::Rc;
|
|||
|
||||
/// Local files client driver
|
||||
pub struct File {
|
||||
// page: Rc<Page>,
|
||||
page: Rc<Page>,
|
||||
}
|
||||
|
||||
impl File {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn init(_page: &Rc<Page>) -> Self {
|
||||
Self { /*page: page.clone()*/ } // @TODO
|
||||
pub fn init(page: &Rc<Page>) -> Self {
|
||||
Self { page: page.clone() } // @TODO
|
||||
}
|
||||
|
||||
pub fn handle(&self, uri: Uri, _feature: Rc<Feature>, cancellable: Cancellable) {
|
||||
use gtk::{gio::File, prelude::FileExtManual};
|
||||
use gtk::{
|
||||
gio::{File, FileQueryInfoFlags, FileType},
|
||||
glib::Priority,
|
||||
prelude::FileExtManual,
|
||||
};
|
||||
|
||||
File::for_uri(&uri.to_string()).load_contents_async(Some(&cancellable), |result| {
|
||||
match result {
|
||||
Ok(_) => todo!(),
|
||||
Err(_) => todo!(),
|
||||
}
|
||||
});
|
||||
// try handle as directory
|
||||
File::for_uri(&uri.to_string()).enumerate_children_async(
|
||||
"standard::content-type",
|
||||
FileQueryInfoFlags::NONE,
|
||||
Priority::DEFAULT,
|
||||
Some(&cancellable),
|
||||
{
|
||||
let cancellable = cancellable.clone();
|
||||
let uri = uri.clone();
|
||||
let _page = self.page.clone();
|
||||
move |result| match result {
|
||||
Ok(file_enumerator) => {
|
||||
for entry in file_enumerator {
|
||||
match entry {
|
||||
Ok(file_info) => match file_info.file_type() {
|
||||
FileType::Unknown => todo!(),
|
||||
FileType::Regular => todo!(),
|
||||
FileType::Directory => todo!(),
|
||||
FileType::SymbolicLink => todo!(),
|
||||
FileType::Special => todo!(),
|
||||
FileType::Shortcut => todo!(),
|
||||
FileType::Mountable => todo!(),
|
||||
_ => todo!(),
|
||||
},
|
||||
Err(_) => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
// is not a directory, try handle as file
|
||||
Err(_) => File::for_uri(&uri.to_string()).load_contents_async(
|
||||
Some(&cancellable),
|
||||
|result| match result {
|
||||
Ok(_) => todo!(),
|
||||
Err(_) => todo!(),
|
||||
},
|
||||
),
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue