Skip to content

Commit

Permalink
src: datalogger: Change to use PathBuf
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulTrombin authored and patrickelectric committed Feb 27, 2024
1 parent b7ecb59 commit e34443c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/data_logger.rs
Original file line number Diff line number Diff line change
@@ -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<DataLogger, std::io::Error> {
pub fn new(file_name: PathBuf) -> Result<DataLogger, std::io::Error> {
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,
Expand Down

0 comments on commit e34443c

Please sign in to comment.