make fuse an optional feature

master
WangRunji 6 years ago
parent 09382c21b8
commit d39d3baea3

@ -4,11 +4,14 @@ version = "0.1.0"
authors = ["WangRunji <wangrunji0408@163.com>"]
edition = "2018"
[features]
use_fuse = ["fuse"]
[dependencies]
time = "0.1"
libc = "0.2"
log = "0.4"
fuse = "0.3"
fuse = { version = "0.3", optional = true }
structopt = "0.2"
env_logger = "0.3"
rcore-fs = { path = "../rcore-fs", features = ["std"] }

@ -1,2 +1,3 @@
#[cfg(feature = "use_fuse")]
pub mod fuse;
pub mod zip;

@ -6,6 +6,7 @@ use structopt::StructOpt;
use rcore_fs::dev::std_impl::StdTimeProvider;
use rcore_fs::vfs::FileSystem;
#[cfg(feature = "use_fuse")]
use rcore_fs_fuse::fuse::VfsFuse;
use rcore_fs_fuse::zip::{unzip_dir, zip_dir};
use rcore_fs_sefs as sefs;
@ -41,6 +42,7 @@ enum Cmd {
Unzip,
/// Mount <image> to <dir>
#[cfg(feature = "use_fuse")]
#[structopt(name = "mount")]
Mount,
}
@ -51,6 +53,7 @@ fn main() {
// open or create
let create = match opt.cmd {
#[cfg(feature = "use_fuse")]
Cmd::Mount => !opt.image.is_dir() && !opt.image.is_file(),
Cmd::Zip => true,
Cmd::Unzip => false,
@ -84,6 +87,7 @@ fn main() {
_ => panic!("unsupported file system"),
};
match opt.cmd {
#[cfg(feature = "use_fuse")]
Cmd::Mount => {
fuse::mount(VfsFuse::new(fs), &opt.dir, &[]).expect("failed to mount fs");
}

Loading…
Cancel
Save