This repository was archived by the owner on Sep 16, 2024. It is now read-only.
File tree 2 files changed +17
-6
lines changed
2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ description = "File Explorer with Dioxus"
10
10
dioxus = { version = " 0.4.0" }
11
11
dioxus-desktop = { version = " 0.4.0" }
12
12
log = " 0.4.14"
13
+ open = " 5.0.0"
13
14
simple_logger = " 4.2.0"
14
15
15
16
Original file line number Diff line number Diff line change 9
9
use dioxus:: prelude:: * ;
10
10
use dioxus_desktop:: { Config , WindowBuilder } ;
11
11
12
+
12
13
fn main ( ) {
13
14
// simple_logger::init_with_level(log::Level::Debug).unwrap();
14
15
dioxus_desktop:: launch_cfg (
@@ -87,11 +88,20 @@ impl Files {
87
88
log:: info!( "Reloading path list for {:?}" , cur_path) ;
88
89
let paths = match std:: fs:: read_dir ( cur_path) {
89
90
Ok ( e) => e,
90
- Err ( err) => {
91
- let err = format ! ( "An error occurred: {:?}" , err) ;
92
- self . err = Some ( err) ;
93
- self . path_stack . pop ( ) ;
94
- return ;
91
+ Err ( err) => { //Likely we're trying to open a file, so let's open it!
92
+ match open:: that ( cur_path) {
93
+ Ok ( _) => {
94
+ log:: info!( "Opened file" ) ;
95
+ return ;
96
+ } ,
97
+ Err ( err) => {
98
+ let err = format ! ( "An error occurred: {:?}" , err) ;
99
+ self . err = Some ( err) ;
100
+ self . path_stack . pop ( ) ;
101
+ return ;
102
+ }
103
+ }
104
+
95
105
}
96
106
} ;
97
107
let collected = paths. collect :: < Vec < _ > > ( ) ;
@@ -105,7 +115,7 @@ impl Files {
105
115
self . path_names
106
116
. push ( path. unwrap ( ) . path ( ) . display ( ) . to_string ( ) ) ;
107
117
}
108
- log:: info!( "path namees are {:#?}" , self . path_names) ;
118
+ log:: info!( "path names are {:#?}" , self . path_names) ;
109
119
}
110
120
111
121
fn go_up ( & mut self ) {
You can’t perform that action at this time.
0 commit comments