Skip to content

Commit 49ecfbc

Browse files
authored
Copy sub-directories within .windows (#949)
Copies any/all sub-folders contained within the `.windows` folder, including blank ones. This makes it easier to deploy language resources, loose xaml, and more.
1 parent 2538dce commit 49ecfbc

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

crates/macros/src/lib.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,20 @@ pub fn build(stream: proc_macro::TokenStream) -> proc_macro::TokenStream {
6464
let _ = cmd.output();
6565

6666
fn copy(source: &::std::path::Path, destination: &mut ::std::path::PathBuf) {
67-
if let ::std::result::Result::Ok(files) = ::std::fs::read_dir(source) {
68-
for file in files.filter_map(|file| file.ok()) {
69-
if let ::std::result::Result::Ok(file_type) = file.file_type() {
70-
if file_type.is_file() {
71-
let path = file.path();
72-
if let ::std::option::Option::Some(filename) = path.file_name() {
73-
let _ = std::fs::create_dir_all(&destination);
74-
destination.push(filename);
67+
if let ::std::result::Result::Ok(entries) = ::std::fs::read_dir(source) {
68+
for entry in entries.filter_map(|entry| entry.ok()) {
69+
if let ::std::result::Result::Ok(entry_type) = entry.file_type() {
70+
let path = entry.path();
71+
if let ::std::option::Option::Some(last_path_component) = path.file_name() {
72+
let _ = ::std::fs::create_dir_all(&destination);
73+
destination.push(last_path_component);
74+
if entry_type.is_file() {
7575
let _ = ::std::fs::copy(path, &destination);
76-
destination.pop();
76+
} else if entry_type.is_dir() {
77+
let _ = ::std::fs::create_dir(&destination);
78+
copy(&path, destination);
7779
}
80+
destination.pop();
7881
}
7982
}
8083
}

0 commit comments

Comments
 (0)