@@ -32,18 +32,10 @@ pub fn is_dir<P: AsRef<Path>>(path: P) -> crate::api::Result<bool> {
3232}
3333
3434fn is_symlink < P : AsRef < Path > > ( path : P ) -> crate :: api:: Result < bool > {
35- // TODO: remove the different implementation once we raise tauri's MSRV to at least 1.58
36- #[ cfg( windows) ]
37- let ret = symlink_metadata ( path)
35+ let path = path. as_ref ( ) ;
36+ symlink_metadata ( path)
3837 . map ( |md| md. is_symlink ( ) )
39- . map_err ( Into :: into) ;
40-
41- #[ cfg( not( windows) ) ]
42- let ret = symlink_metadata ( path)
43- . map ( |md| md. file_type ( ) . is_symlink ( ) )
44- . map_err ( Into :: into) ;
45-
46- ret
38+ . map_err ( |e| crate :: api:: Error :: PathIo ( e, path. to_path_buf ( ) ) )
4739}
4840
4941/// Reads a directory. Can perform recursive operations.
@@ -62,20 +54,19 @@ pub(crate) fn read_dir_with_options<P: AsRef<Path>>(
6254 options : ReadDirOptions < ' _ > ,
6355) -> crate :: api:: Result < Vec < DiskEntry > > {
6456 let mut files_and_dirs: Vec < DiskEntry > = vec ! [ ] ;
65- for entry in fs:: read_dir ( path) ? {
57+ let path = path. as_ref ( ) ;
58+ for entry in fs:: read_dir ( path) . map_err ( |e| crate :: api:: Error :: PathIo ( e, path. to_path_buf ( ) ) ) ? {
6659 let path = entry?. path ( ) ;
67- let path_as_string = path. display ( ) . to_string ( ) ;
6860
69- if let Ok ( flag) = is_dir ( & path_as_string ) {
61+ if let Ok ( flag) = is_dir ( & path ) {
7062 files_and_dirs. push ( DiskEntry {
7163 path : path. clone ( ) ,
7264 children : if flag {
7365 Some (
7466 if recursive
75- && ( !is_symlink ( & path_as_string) ?
76- || options. scope . map ( |s| s. is_allowed ( & path) ) . unwrap_or ( true ) )
67+ && ( !is_symlink ( & path) ? || options. scope . map ( |s| s. is_allowed ( & path) ) . unwrap_or ( true ) )
7768 {
78- read_dir_with_options ( & path_as_string , true , options) ?
69+ read_dir_with_options ( & path , true , options) ?
7970 } else {
8071 vec ! [ ]
8172 } ,
0 commit comments