From e34443cb588a591223678bb0144b24735816884c Mon Sep 17 00:00:00 2001 From: Raul Victor Trombin Date: Thu, 8 Feb 2024 16:27:16 -0300 Subject: [PATCH] src: datalogger: Change to use PathBuf --- src/data_logger.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data_logger.rs b/src/data_logger.rs index c9cb946..929d849 100644 --- a/src/data_logger.rs +++ b/src/data_logger.rs @@ -1,18 +1,18 @@ use chrono::{DateTime, Local}; use std::fs::OpenOptions; use std::io::Write; -use std::path::Path; +use std::path::PathBuf; pub struct DataLogger { file: std::fs::File, } impl DataLogger { - pub fn new(file_name: &str) -> Result { + pub fn new(file_name: PathBuf) -> Result { let mut options = OpenOptions::new(); options.write(true).create(true).append(true); - let file = if !Path::new(file_name).exists() { + let file = if file_name.exists() { let mut file = options.open(file_name)?; writeln!( &mut file,