in releases/rust/esdk/src/dafny_libraries.rs [172:213]
fn SendBytesToFile(
path: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>,
bytes: &::dafny_runtime::Sequence<u8>,
append: bool,
) -> (
bool,
::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>,
) {
let file_name = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(path);
let path = Path::new(&file_name);
let maybe_file = std::fs::OpenOptions::new()
.append(append)
.write(true)
.create(true)
.truncate(!append)
.open(path);
let mut file = match maybe_file {
Err(why) => {
let err_msg = format!(
"couldn't open {} for writing from {}: {}",
path.display(),
curr_dir(),
why
);
let err_msg = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&err_msg);
return (true, err_msg);
}
Ok(file) => file,
};
let bytes = bytes.to_array();
match file.write_all(&bytes) {
Err(why) => {
let err_msg =
format!("couldn't write all bytes to {}: {}", path.display(), why);
let err_msg = dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&err_msg);
(true, err_msg)
}
Ok(_) => (false, dafny_runtime::Sequence::default()),
}
}