22
33//! EFI Shell Protocol v2.2
44
5- use uefi_macros :: unsafe_protocol;
6-
5+ use crate :: proto :: unsafe_protocol;
6+ use crate :: { CStr16 , Char16 , Error , Result , Status , StatusExt } ;
77use core:: ptr;
8-
98use uefi_raw:: protocol:: shell:: ShellProtocol ;
109
11- use crate :: { CStr16 , Char16 , Result , StatusExt } ;
12-
1310/// Shell Protocol
1411#[ derive( Debug ) ]
1512#[ repr( transparent) ]
1613#[ unsafe_protocol( ShellProtocol :: GUID ) ]
1714pub struct Shell ( ShellProtocol ) ;
15+
1816impl Shell {
19- /// Returns the current directory on the specified device
17+ /// Returns the current directory on the specified device.
2018 ///
2119 /// # Arguments
2220 ///
@@ -27,32 +25,27 @@ impl Shell {
2725 ///
2826 /// * `Some(cwd)` - CStr16 containing the current working directory
2927 /// * `None` - Could not retrieve current directory
30- #[ must_use]
31- pub fn current_dir ( & self , file_system_mapping : Option < & CStr16 > ) -> Option < & CStr16 > {
28+ pub fn current_dir ( & self , file_system_mapping : Option < & CStr16 > ) -> Result < & CStr16 > {
3229 let mapping_ptr: * const Char16 = file_system_mapping. map_or ( ptr:: null ( ) , CStr16 :: as_ptr) ;
3330 let cur_dir = unsafe { ( self . 0 . get_cur_dir ) ( mapping_ptr. cast ( ) ) } ;
3431 if cur_dir. is_null ( ) {
35- None
32+ Err ( Error :: new ( Status :: NOT_FOUND , ( ) ) )
3633 } else {
37- unsafe { Some ( CStr16 :: from_ptr ( cur_dir. cast ( ) ) ) }
34+ unsafe { Ok ( CStr16 :: from_ptr ( cur_dir. cast ( ) ) ) }
3835 }
3936 }
4037
4138 /// Changes the current directory on the specified device
4239 ///
4340 /// # Arguments
4441 ///
45- /// * `file_system` - Pointer to the file system's mapped name.
46- /// * `directory` - Points to the directory on the device specified by
42+ /// * `file_system` - File system's mapped name.
43+ /// * `directory` - Directory on the device specified by
4744 /// `file_system`.
4845 ///
49- /// # Returns
50- ///
51- /// * `Status::SUCCESS` - The directory was successfully set
52- ///
5346 /// # Errors
5447 ///
55- /// * `Status::EFI_NOT_FOUND` - The directory does not exist
48+ /// * [ `Status::NOT_FOUND`] - The directory does not exist
5649 pub fn set_current_dir (
5750 & self ,
5851 file_system : Option < & CStr16 > ,
0 commit comments