Skip to content

Commit

Permalink
Better path handling in oak_file_utils
Browse files Browse the repository at this point in the history
Bug: b/377874528

Change-Id: I5930006fd16f8ee1d3dc505f348b028116174438
  • Loading branch information
jblebrun committed Nov 18, 2024
1 parent 7a13aec commit 3ff4ae4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions oak_file_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ impl CompatRlocation for Option<PathBuf> {
#[cfg(feature = "bazel")]
pub fn data_path(path: impl AsRef<Path>) -> PathBuf {
const DATA_PATH_PREFIX: &str = "oak";
let mut pb: PathBuf = DATA_PATH_PREFIX.into();
pb.push(path);

let r = runfiles::Runfiles::create().expect("Couldn't initialize runfiles");
let p = runfiles::rlocation!(r, format!("{DATA_PATH_PREFIX}/{}", path.as_ref().display()))
.compat_wrap()
.expect("Couldn't get runfile path");
let p = runfiles::rlocation!(r, &pb).compat_wrap().expect("Couldn't get runfile path");
if !p.exists() {
panic!("Data dependency not found: {}", path.as_ref().display());
panic!("Data dependency not found: {}", pb.display());
}
p
}

0 comments on commit 3ff4ae4

Please sign in to comment.