Fix(Windows/Profile): Write Windows Profile To Temporary File

This commit is contained in:
Tochukwu Nkemdilim
2018-07-03 22:48:52 +01:00
parent c6e4d7359f
commit e2c9712168
3 changed files with 12 additions and 12 deletions
@@ -1,6 +1,8 @@
use std::fs;
use std::io;
extern crate tempfile;
use self::tempfile::NamedTempFile;
use connectivity::stubs::windows_wifi_profile;
use std::{io, io::Write};
pub(crate) struct NetworkXmlProfileHandler {
pub content: String,
@@ -18,7 +20,10 @@ impl NetworkXmlProfileHandler {
}
/// Recreate the file and dump the processed contents to it
pub fn to_file(&mut self, file_path: &str) -> Result<(), io::Error> {
Ok(fs::write(&file_path, self.content.as_bytes())?)
pub fn write_to_temp_file(&mut self) -> Result<NamedTempFile, io::Error> {
let mut temp_file = NamedTempFile::new()?;
write!(temp_file, "{}", self.content)?;
Ok(temp_file)
}
}