From 26b9ea18d121650bb96cedd11bcd4fca4278bae4 Mon Sep 17 00:00:00 2001 From: Yutao Yuan Date: Thu, 22 Feb 2024 05:59:59 +0800 Subject: [PATCH] Create imported_assets directory with full path (#12022) # Objective - The file asset source currently creates the `imported_assets/Default` directory with relative path, which leads to wrongly created directories when the executable is run with a working directory different from the project root. ## Solution - Use the full path instead. --- crates/bevy_asset/src/io/file/mod.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/bevy_asset/src/io/file/mod.rs b/crates/bevy_asset/src/io/file/mod.rs index 6ee59fab37d24..25bd1e5175f22 100644 --- a/crates/bevy_asset/src/io/file/mod.rs +++ b/crates/bevy_asset/src/io/file/mod.rs @@ -75,16 +75,15 @@ impl FileAssetWriter { /// /// See `get_base_path` below. pub fn new + std::fmt::Debug>(path: P, create_root: bool) -> Self { + let root_path = get_base_path().join(path.as_ref()); if create_root { - if let Err(e) = std::fs::create_dir_all(&path) { + if let Err(e) = std::fs::create_dir_all(&root_path) { error!( "Failed to create root directory {:?} for file asset writer: {:?}", - path, e + root_path, e ); } } - Self { - root_path: get_base_path().join(path.as_ref()), - } + Self { root_path } } }