@@ -4,7 +4,7 @@ use crate::{
4
4
data_types:: FromSliceWithNulError ,
5
5
proto:: { device_path:: DevicePath , Protocol } ,
6
6
table:: boot:: MemoryType ,
7
- unsafe_guid, CStr16 , Char16 , Handle , Status ,
7
+ unsafe_guid, CStr16 , Handle , Status ,
8
8
} ;
9
9
use core:: { ffi:: c_void, mem, slice} ;
10
10
@@ -55,21 +55,12 @@ impl LoadedImage {
55
55
self . device_handle
56
56
}
57
57
58
- /// Return a NULL-terminated Path string including directory and file names .
58
+ /// Get a reference to the `file_path` .
59
59
///
60
- /// `file_path` is a pointer to the file path portion specific to DeviceHandle
61
- /// that the EFI Image was loaded from. It will be empty if the image is loaded
62
- /// from a buffer and the `file_path` is `None`.
63
- ///
64
- /// # Safety
65
- ///
66
- /// The callers should guarantee the image is loaded from file. If the image
67
- /// is loaded from a buffer, make sure not passing an incorrect `DevicePath`,
68
- /// which may case an undefined behavior.
69
- pub unsafe fn file_path ( & self ) -> & CStr16 {
70
- // path name follows the DevicePathHeader.
71
- let path_name = self . file_path . offset ( 1 ) ;
72
- CStr16 :: from_ptr ( path_name. cast :: < Char16 > ( ) )
60
+ /// Return `None` if the pointer to the file path portion specific to
61
+ /// DeviceHandle that the EFI Image was loaded from is null.
62
+ pub fn file_path ( & self ) -> Option < & DevicePath > {
63
+ unsafe { self . file_path . as_ref ( ) }
73
64
}
74
65
75
66
/// Get the load options of the image as a [`&CStr16`].
0 commit comments