aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/file.cpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-10-17 02:56:39 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-10-17 02:56:39 +0300
commit83efec86e7d23d02160719229df4790805432c35 (patch)
tree8d87a40484514043f50d092636fcf9340c06edc4 /src/file.cpp
parentCommandLine: refactoring (diff)
downloadwinapi-common-83efec86e7d23d02160719229df4790805432c35.tar.gz
winapi-common-83efec86e7d23d02160719229df4790805432c35.zip
process_tests: remove temp files
Diffstat (limited to '')
-rw-r--r--src/file.cpp16
1 files changed, 16 insertions, 0 deletions
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