Fix(Windows/Profile): Write Windows Profile To Temporary File
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user