diff --git a/cortex-m-semihosting/src/hio.rs b/cortex-m-semihosting/src/hio.rs index b6b6c7b7..684a5303 100644 --- a/cortex-m-semihosting/src/hio.rs +++ b/cortex-m-semihosting/src/hio.rs @@ -36,7 +36,10 @@ pub fn hstdout() -> Result { open(":tt\0", nr::open::W_TRUNC) } -fn open(name: &str, mode: usize) -> Result { +/// Open a file on the host. The filename must be zero-terminated. +pub fn open(name: &str, mode: usize) -> Result { + debug_assert_eq!(name.bytes().last(), Some(0), "the filename must be zero-terminated"); + let name = name.as_bytes(); match unsafe { syscall!(OPEN, name.as_ptr(), mode, name.len() - 1) } as isize { -1 => Err(()),