diff --git a/gfx/webrender_bindings/src/bindings.rs b/gfx/webrender_bindings/src/bindings.rs index d8e6fad25137..d493a5a4d073 100644 --- a/gfx/webrender_bindings/src/bindings.rs +++ b/gfx/webrender_bindings/src/bindings.rs @@ -1164,20 +1164,26 @@ pub extern "C" fn wr_api_capture( path: *const c_char, bits_raw: u32, ) { - use std::fs::File; + use std::fs::{File, create_dir_all}; use std::io::Write; let cstr = unsafe { CStr::from_ptr(path) }; let path = PathBuf::from(&*cstr.to_string_lossy()); - let revision_path = path.join("wr.txt"); + + let _ = create_dir_all(&path); + match File::create(path.join("wr.txt")) { + Ok(mut file) => { + let revision = include_bytes!("../revision.txt"); + file.write(revision).unwrap(); + } + Err(e) => { + println!("Unable to create path '{:?}' for capture: {:?}", path, e); + return + } + } + let bits = CaptureBits::from_bits(bits_raw as _).unwrap(); dh.api.save_capture(path, bits); - - let revision = include_bytes!("../revision.txt"); - File::create(revision_path) - .unwrap() - .write(revision) - .unwrap(); } #[cfg(target_os = "windows")]