mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Only open the file if we're definitely writing
This commit is contained in:
parent
8a109afee4
commit
0687229a1a
|
@ -22,17 +22,6 @@ pub fn include_wav(input: TokenStream) -> TokenStream {
|
|||
|
||||
let include_path = path.to_string_lossy();
|
||||
|
||||
let wav_reader = hound::WavReader::open(&path)
|
||||
.unwrap_or_else(|_| panic!("Failed to load file {}", include_path));
|
||||
|
||||
assert_eq!(
|
||||
wav_reader.spec().sample_rate,
|
||||
10512,
|
||||
"agb currently only supports sample rate of 10512Hz"
|
||||
);
|
||||
|
||||
let samples = samples_from_reader(wav_reader);
|
||||
|
||||
let out_file_path_include = {
|
||||
let out_dir = std::env::var("OUT_DIR").expect("Expected OUT_DIR");
|
||||
let out_filename = get_out_filename(&path);
|
||||
|
@ -52,6 +41,17 @@ pub fn include_wav(input: TokenStream) -> TokenStream {
|
|||
};
|
||||
|
||||
if should_write {
|
||||
let wav_reader = hound::WavReader::open(&path)
|
||||
.unwrap_or_else(|_| panic!("Failed to load file {}", include_path));
|
||||
|
||||
assert_eq!(
|
||||
wav_reader.spec().sample_rate,
|
||||
10512,
|
||||
"agb currently only supports sample rate of 10512Hz"
|
||||
);
|
||||
|
||||
let samples = samples_from_reader(wav_reader);
|
||||
|
||||
let mut out_file =
|
||||
File::create(&out_file_path).expect("Failed to open file for writing");
|
||||
|
||||
|
|
Loading…
Reference in a new issue