Skip to content

Commit

Permalink
Fix path slashes on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcefrog committed Sep 14, 2023
1 parent 386d2f1 commit 2db2d06
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ fn list_files(tool: &dyn Tool, source: &Utf8Path, options: &Options, json: bool)
.iter()
.map(|source_file| {
json!({
// to_string so that we get it with slashes.
"path": source_file.tree_relative_path.to_string(),
"path": source_file.tree_relative_path.to_slash_path(),
"package": source_file.package.name,
})
})
Expand All @@ -273,7 +272,7 @@ fn list_files(tool: &dyn Tool, source: &Utf8Path, options: &Options, json: bool)
writeln!(out)?;
} else {
for file in files {
writeln!(out, "{}", file.tree_relative_path)?;
writeln!(out, "{}", file.tree_relative_path.to_slash_path())?;
}
}
Ok(())
Expand Down
4 changes: 3 additions & 1 deletion src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use camino::{Utf8Path, Utf8PathBuf};
#[allow(unused_imports)]
use tracing::{debug, info, warn};

use crate::path::Utf8PathSlashes;

/// A Rust source file within a source tree.
///
/// It can be viewed either relative to the source tree (for display)
Expand Down Expand Up @@ -50,7 +52,7 @@ impl SourceFile {

/// Return the path of this file relative to the tree root, with forward slashes.
pub fn tree_relative_slashes(&self) -> String {
self.tree_relative_path.to_string()
self.tree_relative_path.to_slash_path()
}

/// Return the path of this file relative to the base of the source tree.
Expand Down

0 comments on commit 2db2d06

Please sign in to comment.