Resolve resource path relative to qrc path

master
Jos van den Oever 2018-11-24 12:44:59 +01:00
parent f678d441e9
commit 4acf7e3176
1 changed files with 9 additions and 1 deletions

View File

@ -22,7 +22,15 @@ struct QResource {
/// Parse the qrc file, panic if it fails.
fn read_qrc(qrc: &Path) -> RCC {
let bytes = ::std::fs::read(qrc).expect(&format!("Could not read {}", qrc.display()));
deserialize(&bytes[..]).expect(&format!("could not parse {}", qrc.display()))
let mut rcc: RCC = deserialize(&bytes[..]).expect(&format!("could not parse {}", qrc.display()));
for qresource in &mut rcc.qresource {
for file in &mut qresource.file {
let mut p = qrc.parent().unwrap().to_path_buf();
p.push(&file);
*file = p;
}
}
rcc
}
/// Get the list of files that are listed in the qrc file.