2021-10-11 16:37:26 +05:30
|
|
|
use std::ffi::OsString;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2021-07-20 15:07:55 +05:30
|
|
|
//------------------------------------------
|
|
|
|
|
2021-10-11 16:37:26 +05:30
|
|
|
pub fn cpp_cmd<S, I>(cmd: S, args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
S: Into<OsString>,
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
let mut bin = PathBuf::from("./bin");
|
|
|
|
bin.push(Into::<OsString>::into(cmd));
|
|
|
|
duct::cmd(bin.as_path(), args)
|
2021-07-20 15:07:55 +05:30
|
|
|
}
|
|
|
|
|
2021-10-11 16:37:26 +05:30
|
|
|
pub fn rust_cmd<S, I>(cmd: S, args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
S: Into<OsString>,
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
const RUST_PATH: &str = env!(concat!("CARGO_BIN_EXE_", "pdata_tools"));
|
|
|
|
|
|
|
|
let mut all_args = vec![Into::<OsString>::into(cmd)];
|
|
|
|
for a in args {
|
|
|
|
all_args.push(Into::<OsString>::into(a));
|
|
|
|
}
|
|
|
|
|
|
|
|
duct::cmd(RUST_PATH, &all_args)
|
2021-07-20 15:07:55 +05:30
|
|
|
}
|
|
|
|
|
2021-10-11 16:37:26 +05:30
|
|
|
pub fn thin_check_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
rust_cmd("thin_check", args)
|
2021-07-20 15:07:55 +05:30
|
|
|
}
|
|
|
|
|
2021-10-11 16:37:26 +05:30
|
|
|
pub fn thin_rmap_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
cpp_cmd("thin_rmap", args)
|
2021-07-20 15:07:55 +05:30
|
|
|
}
|
|
|
|
|
2021-10-11 16:37:26 +05:30
|
|
|
pub fn thin_generate_metadata_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
cpp_cmd("thin_generate_metadata", args)
|
|
|
|
}
|
2021-07-20 15:07:55 +05:30
|
|
|
|
2021-10-11 16:37:26 +05:30
|
|
|
pub fn thin_generate_mappings_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
cpp_cmd("thin_generate_mappings", args)
|
|
|
|
}
|
2021-07-20 15:07:55 +05:30
|
|
|
|
2021-10-11 16:37:26 +05:30
|
|
|
pub fn thin_generate_damage_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
cpp_cmd("thin_generate_damage", args)
|
|
|
|
}
|
2021-07-20 15:07:55 +05:30
|
|
|
|
2021-10-11 16:37:26 +05:30
|
|
|
pub fn thin_restore_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
rust_cmd("thin_restore", args)
|
|
|
|
}
|
2021-07-20 15:07:55 +05:30
|
|
|
|
2021-10-11 16:37:26 +05:30
|
|
|
pub fn thin_repair_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
rust_cmd("thin_restore", args)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn thin_dump_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
rust_cmd("thin_dump", args)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn thin_delta_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
cpp_cmd("thin_delta", args)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn thin_metadata_pack_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
rust_cmd("thin_metadata_pack", args)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn thin_metadata_unpack_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
rust_cmd("thin_metadata_unpack", args)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cache_check_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
rust_cmd("cache_check", args)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cache_dump_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
rust_cmd("cache_dump", args)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cache_restore_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
rust_cmd("cache_restore", args)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cache_repair_cmd<I>(args: I) -> duct::Expression
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<OsString>,
|
|
|
|
{
|
|
|
|
rust_cmd("cache_repair", args)
|
2021-07-20 15:07:55 +05:30
|
|
|
}
|
|
|
|
|
2021-10-11 16:37:26 +05:30
|
|
|
//------------------------------------------
|
|
|
|
|
|
|
|
pub mod msg {
|
|
|
|
pub const FILE_NOT_FOUND: &str = "Couldn't find input file";
|
2021-07-20 15:07:55 +05:30
|
|
|
pub const MISSING_INPUT_ARG: &str = "The following required arguments were not provided"; // TODO: be specific
|
|
|
|
pub const MISSING_OUTPUT_ARG: &str = "The following required arguments were not provided"; // TODO: be specific
|
|
|
|
pub const BAD_SUPERBLOCK: &str = "bad checksum in superblock";
|
|
|
|
|
|
|
|
pub fn bad_option_hint(option: &str) -> String {
|
|
|
|
format!("Found argument '{}' which wasn't expected", option)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------
|