From eb917463ad90a5cc27e888bc46030126ff47d6c7 Mon Sep 17 00:00:00 2001 From: nmzik Date: Fri, 4 Sep 2026 00:26:54 +0200 Subject: [PATCH] fix File abstraction destructor --- src/common/file.cpp | 2 +- src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp | 4 ++-- tests/KernelFileSystemTests.cpp | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/common/file.cpp b/src/common/file.cpp index 90be6aa13..9b8be2998 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -69,7 +69,7 @@ File::File(): m_p(std::make_unique()) { } File::~File() { - EXIT_IF(m_p->f != nullptr); + Close(); } File::File(const std::filesystem::path& name): m_p(std::make_unique()) { diff --git a/src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp b/src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp index e78a8376e..dd0cf80d7 100644 --- a/src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp +++ b/src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp @@ -102,7 +102,7 @@ void DumpShaderSpirv(const char* stage_name, uint64_t shader_hash, const auto path = Config::GetShaderLogFolder() / fmt::format("{:04d}_new_shader_{}_{:016x}.spv", id++, stage_name, shader_hash); Common::File::CreateDirectories(path.parent_path()); - Common::File file(path, Common::File::Mode::Write); + Common::File file(path); if (file.IsInvalid()) { const auto path_text = Common::PathToString(path); LOGF_COLOR(Log::Color::BrightRed, "Can't create file: %s\n", path_text.c_str()); @@ -131,7 +131,7 @@ void DumpShaderOriginal(const char* stage_name, uint64_t shader_hash, } auto path = base; path += suffix; - Common::File file(path, Common::File::Mode::Write); + Common::File file(path); if (file.IsInvalid()) { const auto path_text = Common::PathToString(path); LOGF_COLOR(Log::Color::BrightRed, "Can't create file: %s\n", path_text.c_str()); diff --git a/tests/KernelFileSystemTests.cpp b/tests/KernelFileSystemTests.cpp index 5ca8ed211..282944969 100644 --- a/tests/KernelFileSystemTests.cpp +++ b/tests/KernelFileSystemTests.cpp @@ -70,7 +70,6 @@ void CheckSaveRename(const std::filesystem::path &root, Common::File result(root / "SDATA000.DAT", Common::File::Mode::Read); Check(!result.IsInvalid(), "open renamed save file"); const auto data = result.ReadWholeBuffer(); - result.Close(); const std::string expected = std::string(payload) + Suffix; Check(data.Size() == expected.size(), "renamed save size"); Check(std::memcmp(data.GetData(), expected.data(), expected.size()) == 0,