@@ -3,7 +3,6 @@ use r_efi::efi::protocols::{device_path, loaded_image_device_path};
33
44use super :: { helpers, unsupported_err} ;
55use crate :: ffi:: { OsStr , OsString } ;
6- use crate :: marker:: PhantomData ;
76use crate :: os:: uefi;
87use crate :: os:: uefi:: ffi:: { OsStrExt , OsStringExt } ;
98use crate :: path:: { self , PathBuf } ;
@@ -41,16 +40,29 @@ pub fn chdir(p: &path::Path) -> io::Result<()> {
4140 if r. is_error ( ) { Err ( io:: Error :: from_raw_os_error ( r. as_usize ( ) ) ) } else { Ok ( ( ) ) }
4241}
4342
44- pub struct SplitPaths < ' a > ( ! , PhantomData < & ' a ( ) > ) ;
43+ pub struct SplitPaths < ' a > ( crate :: os :: uefi :: ffi :: EncodeWide < ' a > ) ;
4544
46- pub fn split_paths ( _unparsed : & OsStr ) -> SplitPaths < ' _ > {
47- panic ! ( "unsupported" )
45+ pub fn split_paths ( unparsed : & OsStr ) -> SplitPaths < ' _ > {
46+ SplitPaths ( unparsed . encode_wide ( ) )
4847}
4948
5049impl < ' a > Iterator for SplitPaths < ' a > {
5150 type Item = PathBuf ;
5251 fn next ( & mut self ) -> Option < PathBuf > {
53- self . 0
52+ let mut buf = Vec :: new ( ) ;
53+
54+ loop {
55+ match self . 0 . next ( ) {
56+ // Ignore consecutive sepearators
57+ Some ( ch) if ch == PATHS_SEP && buf. is_empty ( ) => { }
58+ Some ( ch) if ch == PATHS_SEP => break ,
59+ Some ( ch) => buf. push ( ch) ,
60+ None if buf. is_empty ( ) => return None ,
61+ None => break ,
62+ }
63+ }
64+
65+ Some ( PathBuf :: from ( OsString :: from_wide ( & buf) ) )
5466 }
5567}
5668
0 commit comments