From 8c0f46007f3ac5adec4df869f6382182fc80514c Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 10 Jan 2024 16:47:11 -0800 Subject: [PATCH] add bsp_contents and use --path instead of --vpk --- src/main.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8f08bc0..45a67a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use anyhow::Result as AResult; #[command(propagate_version = true)] struct Cli { #[arg(long)] - vpk:Option, + path:Option, #[command(subcommand)] command: Commands, } @@ -19,6 +19,7 @@ enum Commands { ExtractTextures(PathBufList), ConvertTextures, VPKContents, + BSPContents, DownloadMeshes(PathBufList), Extract(PathBufList), WriteAttributes, @@ -44,8 +45,9 @@ fn main() -> AResult<()> { match cli.command { Commands::Download(map_list)=>download(map_list.maps), Commands::DownloadTextures(pathlist)=>download_textures(pathlist.paths), - Commands::ExtractTextures(pathlist)=>extract_textures(pathlist.paths,cli.vpk.unwrap()), - Commands::VPKContents=>vpk_contents(cli.vpk.unwrap()), + Commands::ExtractTextures(pathlist)=>extract_textures(pathlist.paths,cli.path.unwrap()), + Commands::VPKContents=>vpk_contents(cli.path.unwrap()), + Commands::BSPContents=>bsp_contents(cli.path.unwrap()), Commands::ConvertTextures=>convert_textures(), Commands::DownloadMeshes(pathlist)=>download_meshes(pathlist.paths), Commands::Extract(pathlist)=>extract(pathlist.paths), @@ -1250,4 +1252,12 @@ fn vpk_contents(vpk_path:std::path::PathBuf)->AResult<()>{ println!("vpk label={} entry={:?}",label,entry); } Ok(()) +} + +fn bsp_contents(path:std::path::PathBuf)->AResult<()>{ + let bsp=vbsp::Bsp::read(std::fs::read(path)?.as_ref())?; + for file_name in bsp.pack.into_zip().into_inner().unwrap().file_names(){ + println!("file_name={:?}",file_name); + } + Ok(()) } \ No newline at end of file