llvm.org GIT mirror llvm / 6781c96
Windows/PathV2.inc: Retry rename() for (maximum) 2 seconds. Files might be opend by system scanners (eg. file indexer, virus scanner, &c). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156380 91177308-0d34-0410-b5e6-96231b3b80d8 NAKAMURA Takumi 8 years ago
1 changed file(s) with 15 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
300300 if (error_code ec = UTF8ToUTF16(f, wide_from)) return ec;
301301 if (error_code ec = UTF8ToUTF16(t, wide_to)) return ec;
302302
303 if (!::MoveFileExW(wide_from.begin(), wide_to.begin(),
304 MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING))
305 return windows_error(::GetLastError());
306
307 return error_code::success();
303 error_code ec = error_code::success();
304 for (int i = 0; i < 2000; i++) {
305 if (::MoveFileExW(wide_from.begin(), wide_to.begin(),
306 MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING))
307 return error_code::success();
308 ec = windows_error(::GetLastError());
309 if (ec != windows_error::access_denied)
310 break;
311 // Retry MoveFile() at ACCESS_DENIED.
312 // System scanners (eg. indexer) might open the source file when
313 // It is written and closed.
314 ::Sleep(1);
315 }
316
317 return ec;
308318 }
309319
310320 error_code resize_file(const Twine &path, uint64_t size) {