mirror of
https://github.com/RGBCube/embd-rs
synced 2025-07-26 04:57: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")
|
||||
.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_tokens = quote! {
|
||||
vec![#(#children),*]
|
||||
|
@ -50,7 +60,7 @@ pub fn __include_dir(input: pm1::TokenStream) -> pm1::TokenStream {
|
|||
(quote! {
|
||||
::embed::Dir {
|
||||
children: #children_tokens,
|
||||
path: ::std::path::PathBuf::from(""),
|
||||
path: ::std::path::PathBuf::from(#path_str),
|
||||
}
|
||||
})
|
||||
.into()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue