[PATCH] D38715: Support: On Windows, use CreateFileW to delete files in sys::fs::remove().

Adrian McCarthy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 10 11:31:28 PDT 2017


amccarth added inline comments.


================
Comment at: llvm/lib/Support/Windows/Path.inc:265
 
-  if (ST.type() == file_type::directory_file) {
-    if (!::RemoveDirectoryW(c_str(path_utf16))) {
-      std::error_code EC = mapWindowsError(::GetLastError());
-      if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting)
-        return EC;
-    }
-    return std::error_code();
-  }
-  if (!::DeleteFileW(c_str(path_utf16))) {
+  ScopedFileHandle h(::CreateFileW(
+      c_str(path_utf16), DELETE,
----------------
Zach's right that this is likely a tad faster, but it's also a little less clear.  How about a comment to make it point out that we're using CreateFileW to mark the file/direction for deletion?


https://reviews.llvm.org/D38715





More information about the llvm-commits mailing list