Skip to content

Commit

Permalink
Use Path to form the file_names
Browse files Browse the repository at this point in the history
The current approach fails if the user does not specify the directory
with a trailing /.
  • Loading branch information
janaknat committed Feb 17, 2023
1 parent 2d1423d commit f5683c4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/bin/html_files/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<link rel="stylesheet" href="/html_files/index.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>APerf</title>
</head>
<body>
<h2>APerf</h2>
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ pub fn get_file(dir: String, name: String) -> Result<fs::File> {
for path in fs::read_dir(dir.clone())? {
let mut file_name = path?.file_name().into_string().unwrap();
if file_name.contains(&name) {
file_name = dir + &file_name;
let file_path = Path::new(&dir).join(file_name.clone());
file_name = file_path.to_str().unwrap().to_string();
return Ok(fs::OpenOptions::new()
.read(true)
.open(file_name)
Expand Down

0 comments on commit f5683c4

Please sign in to comment.