-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
218 additions
and
37 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use std::fs::File; | ||
use std::io::BufWriter; | ||
use std::path::{Path, PathBuf}; | ||
|
||
use bff::bigfile::BigFile; | ||
use bff::BufReader; | ||
|
||
use crate::error::BffCliResult; | ||
use crate::extract::{read_names, write_names}; | ||
|
||
pub fn create( | ||
directory: &Path, | ||
bigfile_path: &Path, | ||
in_names: &Vec<PathBuf>, | ||
out_names: &Option<PathBuf>, | ||
) -> BffCliResult<()> { | ||
read_names(bigfile_path, in_names)?; | ||
|
||
let manifest_path = directory.join("manifest.json"); | ||
let manifest_reader = BufReader::new(File::open(manifest_path)?); | ||
let manifest = serde_json::from_reader(manifest_reader)?; | ||
|
||
let mut bigfile = BigFile { | ||
manifest, | ||
objects: Default::default(), | ||
}; | ||
|
||
let resources_path = directory.join("resources"); | ||
std::fs::create_dir_all(&resources_path)?; | ||
|
||
for file in std::fs::read_dir(resources_path)? { | ||
let path = file?.path(); | ||
if path.is_file() { | ||
let mut file_reader = BufReader::new(File::open(&path)?); | ||
let resource = bigfile.read_resource(&mut file_reader)?; | ||
bigfile.objects.insert(resource.name, resource); | ||
} | ||
} | ||
|
||
let mut bigfile_writer = BufWriter::new(File::create(bigfile_path)?); | ||
bigfile.write(&mut bigfile_writer, None)?; | ||
|
||
write_names(out_names)?; | ||
|
||
Ok(()) | ||
} |
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
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
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
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
Oops, something went wrong.