Fix buf len update of read_link to Utf8CStrBuf

This commit is contained in:
LoveSy 2023-09-19 02:21:19 +08:00 committed by John Wu
parent 877aeb66cb
commit 5fbd3e5c65

View File

@ -411,8 +411,12 @@ impl FsPath {
pub fn read_link(&self, buf: &mut dyn Utf8CStrBuf) -> io::Result<()> { pub fn read_link(&self, buf: &mut dyn Utf8CStrBuf) -> io::Result<()> {
buf.clear(); buf.clear();
unsafe { readlink_unsafe(self.as_ptr(), buf.as_mut_ptr().cast(), buf.capacity()) } unsafe {
.as_os_err() let c = readlink_unsafe(self.as_ptr(), buf.as_mut_ptr().cast(), buf.capacity());
c.check_os_err()?;
buf.set_len(c as usize);
}
Ok(())
} }
pub fn mkdirs(&self, mode: mode_t) -> io::Result<()> { pub fn mkdirs(&self, mode: mode_t) -> io::Result<()> {