Skip to content

Commit

Permalink
Use path in read_matrix_market
Browse files Browse the repository at this point in the history
  • Loading branch information
cpmech committed Sep 19, 2023
1 parent 09455ce commit d1d371c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions russell_sparse/src/read_matrix_market.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use super::SparseTriplet;
use crate::StrError;
use std::ffi::OsStr;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;

struct MatrixMarketData {
// header
Expand Down Expand Up @@ -165,7 +167,7 @@ impl MatrixMarketData {
///
/// # Input
///
/// * `filepath` -- The full file path with filename
/// * `full_path` -- may be a String, &str, or Path
/// * `sym_mirror` -- Tells the reader to mirror the **off diagonal** entries,
/// if the symmetric option is found in the header.
///
Expand Down Expand Up @@ -323,8 +325,12 @@ impl MatrixMarketData {
/// Ok(())
/// }
/// ```
pub fn read_matrix_market(filepath: &String, sym_mirror: bool) -> Result<(SparseTriplet, bool), StrError> {
let input = File::open(filepath).map_err(|_| "cannot open file")?;
pub fn read_matrix_market<P>(full_path: &P, sym_mirror: bool) -> Result<(SparseTriplet, bool), StrError>
where
P: AsRef<OsStr> + ?Sized,
{
let path = Path::new(full_path).to_path_buf();
let input = File::open(path).map_err(|_| "cannot open file")?;
let buffered = BufReader::new(input);
let mut lines_iter = buffered.lines();

Expand Down

0 comments on commit d1d371c

Please sign in to comment.