mirror of
https://github.com/fluencelabs/wasmer
synced 2025-04-25 10:22:19 +00:00
fix cargo toml and fmt
This commit is contained in:
parent
bd697487aa
commit
d95b62a467
@ -39,9 +39,8 @@ glob = "0.2.11"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["fast-tests"]
|
default = ["fast-tests"]
|
||||||
vfs = ["wasmer-runtime-abi", "wasmer-emscripten/vfs"]
|
|
||||||
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
|
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
|
||||||
default = ["fast-tests"]
|
|
||||||
# This feature will allow cargo test to run much faster
|
# This feature will allow cargo test to run much faster
|
||||||
fast-tests = []
|
fast-tests = []
|
||||||
llvm = ["wasmer-llvm-backend"]
|
llvm = ["wasmer-llvm-backend"]
|
||||||
|
vfs = ["wasmer-runtime-abi", "wasmer-emscripten/vfs"]
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use zbox::{init_env, RepoOpener, Repo, OpenOptions};
|
|
||||||
use std::io::Read;
|
|
||||||
use std::path::{Path, PathBuf};
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
use std::io::Read;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use zbox::{init_env, OpenOptions, Repo, RepoOpener};
|
||||||
|
|
||||||
pub type Fd = isize;
|
pub type Fd = isize;
|
||||||
|
|
||||||
@ -23,13 +23,14 @@ impl Vfs {
|
|||||||
pub fn from_tar_bytes<Reader: Read>(tar_bytes: Reader) -> Result<Self, failure::Error> {
|
pub fn from_tar_bytes<Reader: Read>(tar_bytes: Reader) -> Result<Self, failure::Error> {
|
||||||
let mut ar = tar::Archive::new(tar_bytes);
|
let mut ar = tar::Archive::new(tar_bytes);
|
||||||
init_env();
|
init_env();
|
||||||
let mut repo = RepoOpener::new().create(true).open("mem://wasmer_fs", "").unwrap();
|
let mut repo = RepoOpener::new()
|
||||||
|
.create(true)
|
||||||
|
.open("mem://wasmer_fs", "")
|
||||||
|
.unwrap();
|
||||||
for entry in ar.entries()? {
|
for entry in ar.entries()? {
|
||||||
let mut entry = entry?;
|
let mut entry = entry?;
|
||||||
let path = convert_to_absolute_path(entry.path().unwrap());
|
let path = convert_to_absolute_path(entry.path().unwrap());
|
||||||
let mut file = OpenOptions::new()
|
let mut file = OpenOptions::new().create(true).open(&mut repo, path)?;
|
||||||
.create(true)
|
|
||||||
.open(&mut repo, path)?;
|
|
||||||
io::copy(&mut entry, &mut file)?;
|
io::copy(&mut entry, &mut file)?;
|
||||||
file.finish().unwrap();
|
file.finish().unwrap();
|
||||||
}
|
}
|
||||||
@ -41,11 +42,7 @@ impl Vfs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// like read(2), will read the data for the file descriptor
|
/// like read(2), will read the data for the file descriptor
|
||||||
pub fn read_file(
|
pub fn read_file(&mut self, fd: Fd, buf: &mut [u8]) -> Result<usize, failure::Error> {
|
||||||
&mut self,
|
|
||||||
fd: Fd,
|
|
||||||
buf: &mut [u8],
|
|
||||||
) -> Result<usize, failure::Error> {
|
|
||||||
self.fd_map
|
self.fd_map
|
||||||
.get_mut(&fd)
|
.get_mut(&fd)
|
||||||
.ok_or(VfsError::FileDescriptorNotExist)?
|
.ok_or(VfsError::FileDescriptorNotExist)?
|
||||||
@ -60,11 +57,10 @@ impl Vfs {
|
|||||||
let file = OpenOptions::new().open(&mut repo, path)?;
|
let file = OpenOptions::new().open(&mut repo, path)?;
|
||||||
let fd = if self.fd_map.len() == 0 {
|
let fd = if self.fd_map.len() == 0 {
|
||||||
0
|
0
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
let fd = *match self.fd_map.keys().max() {
|
let fd = *match self.fd_map.keys().max() {
|
||||||
Some(fd) => fd,
|
Some(fd) => fd,
|
||||||
None => return Err(VfsError::CouldNotGetNextLowestFileDescriptor.into())
|
None => return Err(VfsError::CouldNotGetNextLowestFileDescriptor.into()),
|
||||||
};
|
};
|
||||||
fd + 1
|
fd + 1
|
||||||
};
|
};
|
||||||
@ -81,23 +77,20 @@ pub enum VfsError {
|
|||||||
CouldNotGetNextLowestFileDescriptor,
|
CouldNotGetNextLowestFileDescriptor,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn convert_to_absolute_path<P: AsRef<Path>>(path: P) -> PathBuf {
|
fn convert_to_absolute_path<P: AsRef<Path>>(path: P) -> PathBuf {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
if path.is_relative() {
|
if path.is_relative() {
|
||||||
std::path::PathBuf::from("/").join(path)
|
std::path::PathBuf::from("/").join(path)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
path.to_path_buf()
|
path.to_path_buf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod open_test {
|
mod open_test {
|
||||||
|
use crate::vfs::vfs::Vfs;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use crate::vfs::vfs::Vfs;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn open_files() {
|
fn open_files() {
|
||||||
@ -168,10 +161,10 @@ mod open_test {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod read_test {
|
mod read_test {
|
||||||
|
use crate::vfs::vfs::Vfs;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use tempdir;
|
use tempdir;
|
||||||
use crate::vfs::vfs::Vfs;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_archive() {
|
fn empty_archive() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user