fix: Debug图片保存目录 (#15250)

This commit is contained in:
Hao Guan
2026-01-02 17:26:22 +08:00
committed by GitHub
parent fee016634e
commit 742e71a893
2 changed files with 9 additions and 3 deletions

View File

@@ -81,6 +81,11 @@ inline bool save_debug_image(
static std::mutex s_mutex;
auto norm_dir = relative_dir.lexically_normal();
const auto& base_dir = UserDir.get();
auto res = std::mismatch(base_dir.begin(), base_dir.end(), norm_dir.begin());
if (norm_dir.is_relative() && res.first != base_dir.end()) {
norm_dir = base_dir / norm_dir;
}
if (auto_clean) {
std::lock_guard<std::mutex> lock(s_mutex);

View File

@@ -19,12 +19,13 @@ public:
const std::filesystem::path& get() const noexcept { return dir_; }
bool set(std::filesystem::path dir)
bool set(const std::filesystem::path& dir)
{
if (!std::filesystem::exists(dir) || !std::filesystem::is_directory(dir)) {
auto norm_dir = dir.lexically_normal();
if (!std::filesystem::exists(norm_dir) || !std::filesystem::is_directory(norm_dir)) {
return false;
}
dir_ = std::move(dir);
dir_ = std::move(norm_dir);
return true;
}