通过 Cargo 工具进行安装。
cargo install ncmdump
或者通过 GitHub Release 下载。
ncmdump [FILES]...
Usage: ncmdump [OPTIONS] [FILES]...
Arguments:
[FILES]... Specified the files to convert
Options:
-o, --output <OUTPUT> Specified the output directory. Default it's the same directory with input file
-v, --verbose Verbosely list files processing
-h, --help Print help
-V, --version Print version
在你的 Cargo.toml
文件中添加依赖:
ncmdump = "0.8.0"
或者,如果安装了 cargo-edit,你可以使用命令:
cargo add ncmdump
use std::fs::File;
use std::path::Path;
use anyhow::Result;
use ncmdump::Ncmdump;
fn main() -> Result<()> {
use std::io::Write;
let file = File::open("res/test.ncm")?;
let mut ncm = Ncmdump::from_reader(file)?;
let music = ncm.get_data()?;
let mut target = File::options()
.create(true)
.write(true)
.open("res/test.flac")?;
target.write_all(&music)?;
Ok(())
}
更多的用法, 可以查看文档.