From 83efec86e7d23d02160719229df4790805432c35 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 17 Oct 2020 02:56:39 +0300 Subject: process_tests: remove temp files --- src/file.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index c6a4ff4..165f36e 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -69,6 +69,14 @@ Handle open_file(const std::wstring& path, const CreateFileParams& params) { return Handle{handle}; } +void remove_file(const std::wstring& path) { + const auto ret = ::DeleteFileW(path.c_str()); + + if (!ret) { + throw error::windows(GetLastError(), "DeleteFileW"); + } +} + } // namespace Handle File::open_r(const std::string& path) { @@ -87,4 +95,12 @@ Handle File::open_w(const CanonicalPath& path) { return open_file(to_system_path(path), CreateFileParams::write()); } +void File::remove(const std::string& path) { + remove_file(to_system_path(path)); +} + +void File::remove(const CanonicalPath& path) { + remove_file(to_system_path(path)); +} + } // namespace winapi -- cgit v1.2.3