Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@ryansg.com>2020-04-07 11:40:19 -0400
committerMike Gerwitz <mike.gerwitz@ryansg.com>2020-04-28 09:06:25 -0400
commit0f423f3b24837cb2d6d5dc254427751ff709ab54 (patch)
treef8e4b6731c9ef28edf8e01198c654355e1b660f9 /tamer/src/ld/poc.rs
parent4a7e00c404c14261c4a7d492b54c84e22e060e37 (diff)
downloadtame-0f423f3b24837cb2d6d5dc254427751ff709ab54.tar.gz
tame-0f423f3b24837cb2d6d5dc254427751ff709ab54.tar.bz2
tame-0f423f3b24837cb2d6d5dc254427751ff709ab54.zip
[DEV-7084] TAMER: Simplify path canonicalization
This abstracts away the canonicalizer and solves the problem whereby canonicalization was not being performed prior to recording whether a path has been visited. This ensures that multiple relative paths to the same file will be properly recognized as visited.
Diffstat (limited to 'tamer/src/ld/poc.rs')
-rw-r--r--tamer/src/ld/poc.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/tamer/src/ld/poc.rs b/tamer/src/ld/poc.rs
index 80abaed..0a395ba 100644
--- a/tamer/src/ld/poc.rs
+++ b/tamer/src/ld/poc.rs
@@ -21,7 +21,7 @@
//! banished to its own file to try to make that more clear.
use crate::fs::{
- CanonicalFile, Filesystem, VisitOnceFile, VisitOnceFilesystem,
+ Filesystem, FsCanonicalizer, PathFile, VisitOnceFile, VisitOnceFilesystem,
};
use crate::global;
use crate::ir::asg::{
@@ -36,7 +36,7 @@ use fxhash::FxBuildHasher;
use std::error::Error;
use std::fs;
use std::io::BufReader;
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
type LinkerAsg<'i> = DefaultAsg<'i, IdentObject<'i>, global::ProgIdentSize>;
@@ -111,14 +111,14 @@ pub fn main(package_path: &str, output: &str) -> Result<(), Box<dyn Error>> {
Ok(())
}
-fn load_xmlo<'a, 'i, I: Interner<'i>>(
- path_str: &'a str,
- fs: &mut VisitOnceFilesystem<FxBuildHasher>,
+fn load_xmlo<'a, 'i, I: Interner<'i>, P: AsRef<Path>>(
+ path_str: P,
+ fs: &mut VisitOnceFilesystem<FsCanonicalizer, FxBuildHasher>,
depgraph: &mut LinkerAsg<'i>,
interner: &'i I,
state: LinkerAsgBuilderState<'i>,
) -> Result<LinkerAsgBuilderState<'i>, Box<dyn Error>> {
- let cfile: CanonicalFile<BufReader<fs::File>> = match fs.open(path_str)? {
+ let cfile: PathFile<BufReader<fs::File>> = match fs.open(path_str)? {
VisitOnceFile::FirstVisit(file) => file,
VisitOnceFile::Visited => return Ok(state),
};
@@ -139,11 +139,7 @@ fn load_xmlo<'a, 'i, I: Interner<'i>>(
path_buf.push(relpath);
path_buf.set_extension("xmlo");
- // println!("Trying {:?}", path_buf);
- let path_abs = path_buf.canonicalize()?;
- let path = path_abs.to_str().unwrap();
-
- state = load_xmlo(path, fs, depgraph, interner, state)?;
+ state = load_xmlo(path_buf, fs, depgraph, interner, state)?;
}
Ok(state)