From f04ddd22eb1de9535d0fc25f186c6c7b5d8432f8 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Fri, 3 May 2019 12:21:41 +0800 Subject: [PATCH] Support symlink for unzip --- rcore-fs-fuse/src/zip.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rcore-fs-fuse/src/zip.rs b/rcore-fs-fuse/src/zip.rs index 16da115..1be87ee 100644 --- a/rcore-fs-fuse/src/zip.rs +++ b/rcore-fs-fuse/src/zip.rs @@ -4,6 +4,7 @@ use std::io::{Read, Write}; use std::mem::uninitialized; use std::os::unix::ffi::OsStrExt; use std::path::Path; +use std::str; use std::sync::Arc; use rcore_fs::vfs::{FileType, INode}; @@ -67,6 +68,11 @@ pub fn unzip_dir(path: &Path, inode: Arc) -> Result<(), Box> { fs::create_dir(&path)?; 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"), } }