mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Use PathBuf to load files
Former-commit-id: b72084fab1b8faeabc47eee927654f963643bb78
This commit is contained in:
parent
14b28a4a17
commit
d55e803ab5
@ -7,6 +7,7 @@ use std::{
|
||||
fs::File,
|
||||
io::BufReader,
|
||||
io::Read,
|
||||
path::PathBuf,
|
||||
sync::{Arc, RwLock},
|
||||
};
|
||||
|
||||
@ -92,8 +93,9 @@ impl Asset for DotVoxData {
|
||||
// TODO: System to load file from specifiers (e.g.: "core.ui.backgrounds.city").
|
||||
fn try_open_with_path(name: &str) -> Option<File> {
|
||||
debug!("Trying to access \"{}\"", name);
|
||||
// TODO: Don't do this?
|
||||
// If it's stupid but it works...
|
||||
let abs_path = std::env::current_dir().expect("No current directory?");
|
||||
// TODO: don't do this?
|
||||
// if it's stupid and it works..,
|
||||
[
|
||||
"assets".to_string(),
|
||||
"../assets".to_string(), /* optimizations */
|
||||
@ -105,7 +107,12 @@ fn try_open_with_path(name: &str) -> Option<File> {
|
||||
[env!("CARGO_MANIFEST_DIR"), "/../../../assets"].concat(),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|bp| [bp, name].concat())
|
||||
.map(|bp| {
|
||||
let mut p = abs_path.clone();
|
||||
p.push(bp);
|
||||
p.push(name);
|
||||
p
|
||||
})
|
||||
.find_map(|ref filename| File::open(filename).ok())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user