-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from INTO-CPS-Association/cli
Cli
- Loading branch information
Showing
16 changed files
with
863 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[workspace] | ||
|
||
members = ["fmi2api", "integration-tests", "cli"] | ||
members = ["common", "fmi2api", "integration-tests", "cli"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
authors = ["Christian Legaard <[email protected]>"] | ||
edition = "2018" | ||
name = "unifmu" | ||
version = "0.0.4" | ||
version = "0.0.5" | ||
|
||
[dependencies] | ||
|
||
|
@@ -11,8 +11,15 @@ env_logger = "*" | |
fs_extra = "*" | ||
lazy_static = "*" | ||
libc = "*" | ||
dlopen = "*" | ||
dlopen_derive = "*" | ||
log = "*" | ||
num_enum = "*" | ||
rust-embed = "6.0.0" | ||
structopt = "*" | ||
tempfile = "*" | ||
url = "*" | ||
walkdir = "*" | ||
zip = { version = "*", default-features = false, features = ["deflate"] } | ||
|
||
common = { path = "../common" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use std::path::Path; | ||
|
||
pub struct BenchmarkConfig {} | ||
|
||
impl Default for BenchmarkConfig { | ||
fn default() -> Self { | ||
Self {} | ||
} | ||
} | ||
|
||
pub fn benchmark(rootdir: &Path, config: &BenchmarkConfig) { | ||
todo!(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use log::info; | ||
use std::fs::File; | ||
use std::io::prelude::*; | ||
use std::io::{Seek, Write}; | ||
use std::iter::Iterator; | ||
use std::path::Path; | ||
use walkdir::{DirEntry, WalkDir}; | ||
use zip::result::ZipError; | ||
use zip::write::FileOptions; | ||
|
||
pub fn zip_dir<T>( | ||
it: &mut dyn Iterator<Item = DirEntry>, | ||
prefix: &str, | ||
writer: T, | ||
method: zip::CompressionMethod, | ||
) -> zip::result::ZipResult<()> | ||
where | ||
T: Write + Seek, | ||
{ | ||
let mut zip = zip::ZipWriter::new(writer); | ||
let options = FileOptions::default() | ||
.compression_method(method) | ||
.unix_permissions(0o755); | ||
|
||
let mut buffer = Vec::new(); | ||
for entry in it { | ||
let path = entry.path(); | ||
let name = path.strip_prefix(Path::new(prefix)).unwrap(); | ||
|
||
// Write file or directory explicitly | ||
// Some unzip tools unzip files with directory paths correctly, some do not! | ||
if path.is_file() { | ||
info!("adding file {:?} as {:?} ...", path, name); | ||
#[allow(deprecated)] | ||
zip.start_file_from_path(name, options)?; | ||
let mut f = File::open(path)?; | ||
|
||
f.read_to_end(&mut buffer)?; | ||
zip.write_all(&*buffer)?; | ||
buffer.clear(); | ||
} else if name.as_os_str().len() != 0 { | ||
// Only if not root! Avoids path spec / warning | ||
// and mapname conversion failed error on unzip | ||
info!("adding dir {:?} as {:?} ...", path, name); | ||
#[allow(deprecated)] | ||
zip.add_directory_from_path(name, options)?; | ||
} | ||
} | ||
zip.finish()?; | ||
Result::Ok(()) | ||
} |
Oops, something went wrong.