Support symlink for unzip

master
Jiajie Chen 6 years ago
parent 037d00f566
commit f04ddd22eb

@ -4,6 +4,7 @@ use std::io::{Read, Write};
use std::mem::uninitialized; use std::mem::uninitialized;
use std::os::unix::ffi::OsStrExt; use std::os::unix::ffi::OsStrExt;
use std::path::Path; use std::path::Path;
use std::str;
use std::sync::Arc; use std::sync::Arc;
use rcore_fs::vfs::{FileType, INode}; use rcore_fs::vfs::{FileType, INode};
@ -67,6 +68,11 @@ pub fn unzip_dir(path: &Path, inode: Arc<INode>) -> Result<(), Box<Error>> {
fs::create_dir(&path)?; fs::create_dir(&path)?;
unzip_dir(path.as_path(), inode)?; unzip_dir(path.as_path(), inode)?;
} }
FileType::SymLink => {
let mut buf: [u8; BUF_SIZE] = unsafe { uninitialized() };
let len = inode.read_at(0, buf.as_mut())?;
std::os::unix::fs::symlink(path, str::from_utf8(&buf[..len]).unwrap())?;
}
_ => panic!("unsupported file type"), _ => panic!("unsupported file type"),
} }
} }

Loading…
Cancel
Save