http://llvm.org/bugs/show_bug.cgi?id=22512
Bug ID: 22512
Summary: Rewriter::overwriteChangedFiles() probably fail when
target's driver differs with system tempolary dir
Product: clang
Version: 3.3
Hardware: PC
OS: Windows XP
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
As title mentioned, when I try calling Rewriter::overwriteChangedFiles, clang
reports a WINDOWS error 1224 - The requested operation cannot be performed on a
file with
a user-mapped section open (maybe 20 errors in 100 sample files). after some
debuging and analysing, I found that my target file locates in driver E, while
system tempolary directory locates in driver C. clang save all changes first in
a middle file in tempolary dir, then replace the target file via
llvm::sys::fs::rename(), this causes fail! If the source and target file
locates in the same driver, rename will always be successful and my problem be
solved.
append a few code as below:
~AtomicallyMovedFile() {
......
if (llvm::error_code ec = llvm::sys::fs::rename(TempFilename.str(),
Filename)) {
// rename fail, try the other way :
// 1. move src to the same driver of target
// 2. rename to target
SmallString<128> TmpInSameDriver = Filename;
TmpInSameDriver += "_tmp";
llvm::error_code ec2 = llvm::sys::fs::rename(TempFilename.str(),
TmpInSameDriver.str());
ec2 = llvm::sys::fs::rename(TmpInSameDriver.str(), Filename);
if (!ec2) return;
......
}
}
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs