<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Rewriter::overwriteChangedFiles() probably fail when target's driver differs with system tempolary dir"
href="http://llvm.org/bugs/show_bug.cgi?id=22512">22512</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Rewriter::overwriteChangedFiles() probably fail when target's driver differs with system tempolary dir
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.3
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows XP
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>colinx.xu@huawei.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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;
......
}
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>