Normalize MIRI_TEMP before using it
This commit is contained in:
parent
9e6320f101
commit
4eea02e725
1 changed files with 13 additions and 1 deletions
|
|
@ -29,7 +29,19 @@ fn main() {
|
|||
}
|
||||
|
||||
fn tmp() -> PathBuf {
|
||||
std::env::var("MIRI_TEMP").map(PathBuf::from).unwrap_or_else(|_| std::env::temp_dir())
|
||||
std::env::var("MIRI_TEMP")
|
||||
.map(|tmp| {
|
||||
// MIRI_TEMP is set outside of our emulated
|
||||
// program, so it may have path separators that don't
|
||||
// correspond to our target platform. We normalize them here
|
||||
// before constructing a `PathBuf`
|
||||
|
||||
#[cfg(windows)]
|
||||
return PathBuf::from(tmp.replace("/", "\\"));
|
||||
|
||||
#[cfg(not(windows))]
|
||||
return PathBuf::from(tmp.replace("\\", "/"));
|
||||
}).unwrap_or_else(|_| std::env::temp_dir())
|
||||
}
|
||||
|
||||
/// Prepare: compute filename and make sure the file does not exist.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue