From 9161d18711b81dc603ef87024aa44a3791be32fd Mon Sep 17 00:00:00 2001 From: klayoutmatthias Date: Thu, 9 Nov 2023 21:42:07 +0100 Subject: [PATCH] Allowing tl::rm_file to remove files even if write protected --- src/tl/tl/tlFileUtils.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tl/tl/tlFileUtils.cc b/src/tl/tl/tlFileUtils.cc index 0da94a6e1..0112910de 100644 --- a/src/tl/tl/tlFileUtils.cc +++ b/src/tl/tl/tlFileUtils.cc @@ -484,7 +484,9 @@ bool rename_file (const std::string &path, const std::string &new_name) bool rm_file (const std::string &path) { #if defined(_WIN32) - return _wunlink (tl::to_wstring (path).c_str ()) == 0; + std::wstring wpath = tl::to_wstring (path); + _wchmod (wpath.c_str (), _S_IREAD | _S_IWRITE); + return _wunlink (wpath.c_str ()) == 0; #else return unlink (tl::to_local (path).c_str ()) == 0; #endif