alexcrichton / ssh2-rs

Rust bindings for libssh2
https://docs.rs/ssh2
Apache License 2.0
485 stars 147 forks source link

panic Utf8Error #319

Open lunxinfeng opened 3 months ago

lunxinfeng commented 3 months ago

Thank you for this library, but I found a problem. I have a non-utf8 encoded file on my server. When I access the server path on the Windows platform, it panics.

called Result::unwrap() on an Err value: Utf8Error { valid_up_to: 10, error_len: Some(1) }

sftp.readdir(&Path::new("/usr/xxxx/"));
#[cfg(windows)]
fn mkpath(v: Vec<u8>) -> PathBuf {
    use std::str;
    PathBuf::from(str::from_utf8(&v).unwrap())
}