Skip to content

Commit 97fc739

Browse files
committed
std: sys: fs: uefi: Implement File::tell
- Just a call to get_position - Tested with OVMF on QEMU Signed-off-by: Ayush Singh <ayush@beagleboard.org>
1 parent 3fda0e4 commit 97fc739

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

library/std/src/sys/fs/uefi.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl File {
364364
}
365365

366366
pub fn tell(&self) -> io::Result<u64> {
367-
unsupported()
367+
self.0.position()
368368
}
369369

370370
pub fn duplicate(&self) -> io::Result<File> {
@@ -734,6 +734,14 @@ mod uefi_fs {
734734
if r.is_error() { Err(io::Error::from_raw_os_error(r.as_usize())) } else { Ok(()) }
735735
}
736736

737+
pub(crate) fn position(&self) -> io::Result<u64> {
738+
let file_ptr = self.protocol.as_ptr();
739+
let mut pos = 0;
740+
741+
let r = unsafe { ((*file_ptr).get_position)(file_ptr, &mut pos) };
742+
if r.is_error() { Err(io::Error::from_raw_os_error(r.as_usize())) } else { Ok(pos) }
743+
}
744+
737745
pub(crate) fn delete(self) -> io::Result<()> {
738746
let file_ptr = self.protocol.as_ptr();
739747
let r = unsafe { ((*file_ptr).delete)(file_ptr) };

0 commit comments

Comments
 (0)