From b254f75968e1a5692fa872fcfda5eaa1a0ed561d Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Wed, 16 Oct 2024 09:49:55 +0200 Subject: safer path from handle (#195) * remove PathFromHandle that throws to give better context on failures --- src/zenutil/basicfile.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/zenutil/basicfile.cpp') diff --git a/src/zenutil/basicfile.cpp b/src/zenutil/basicfile.cpp index 575d153b2..73f27b587 100644 --- a/src/zenutil/basicfile.cpp +++ b/src/zenutil/basicfile.cpp @@ -858,13 +858,16 @@ TEST_CASE("TemporaryFile") SUBCASE("DeleteOnClose") { - TemporaryFile TmpFile; - std::error_code Ec; - TmpFile.CreateTemporary(std::filesystem::current_path(), Ec); - CHECK(!Ec); - CHECK(std::filesystem::exists(TmpFile.GetPath())); - TmpFile.Close(); - CHECK(std::filesystem::exists(TmpFile.GetPath()) == false); + std::filesystem::path Path; + { + TemporaryFile TmpFile; + std::error_code Ec; + TmpFile.CreateTemporary(std::filesystem::current_path(), Ec); + CHECK(!Ec); + Path = TmpFile.GetPath(); + CHECK(std::filesystem::exists(Path)); + } + CHECK(std::filesystem::exists(Path) == false); } SUBCASE("MoveIntoPlace") -- cgit v1.2.3