When loading a movie from the filesystem outside of the core, ensure that the URL is properly made absolute.
This commit is contained in:
parent
c926da8888
commit
5d15f5bfe3
|
@ -1,3 +1,4 @@
|
|||
use crate::backend::navigator::url_from_relative_path;
|
||||
use gc_arena::Collect;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
@ -53,7 +54,12 @@ impl SwfMovie {
|
|||
|
||||
/// Utility method to construct a movie from a file on disk.
|
||||
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, Error> {
|
||||
let url = path.as_ref().to_string_lossy().to_owned().to_string();
|
||||
let mut url = path.as_ref().to_string_lossy().to_owned().to_string();
|
||||
let cwd = std::env::current_dir()?;
|
||||
if let Ok(abs_url) = url_from_relative_path(cwd, &url) {
|
||||
url = abs_url.into_string();
|
||||
}
|
||||
|
||||
let data = std::fs::read(path)?;
|
||||
Self::from_data(&data, Some(url))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue