mirror of
https://github.com/RGBCube/embd-rs
synced 2025-07-27 05:27:44 +00:00
Fix importing parent files
This commit is contained in:
parent
77520c0364
commit
b2be0579f8
1 changed files with 11 additions and 1 deletions
|
@ -42,6 +42,16 @@ pub fn __include_dir(input: pm1::TokenStream) -> pm1::TokenStream {
|
||||||
.expect("Failed to get the parent of file")
|
.expect("Failed to get the parent of file")
|
||||||
.join(path);
|
.join(path);
|
||||||
|
|
||||||
|
let path = if !path.ends_with("..") {
|
||||||
|
path
|
||||||
|
} else {
|
||||||
|
path.parent().unwrap().to_path_buf()
|
||||||
|
};
|
||||||
|
|
||||||
|
let path_str = path
|
||||||
|
.to_str()
|
||||||
|
.expect("Failed to get the string representation of PathBuf");
|
||||||
|
|
||||||
let children = read_dir(&path, &path);
|
let children = read_dir(&path, &path);
|
||||||
let children_tokens = quote! {
|
let children_tokens = quote! {
|
||||||
vec![#(#children),*]
|
vec![#(#children),*]
|
||||||
|
@ -50,7 +60,7 @@ pub fn __include_dir(input: pm1::TokenStream) -> pm1::TokenStream {
|
||||||
(quote! {
|
(quote! {
|
||||||
::embed::Dir {
|
::embed::Dir {
|
||||||
children: #children_tokens,
|
children: #children_tokens,
|
||||||
path: ::std::path::PathBuf::from(""),
|
path: ::std::path::PathBuf::from(#path_str),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.into()
|
.into()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue