diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2010-08-24 16:34:12 +0200 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2010-08-24 16:34:12 +0200 |
commit | 7c122f33c4bf8caec1cf8b250d512b65c3c574ca (patch) | |
tree | 81786b34b546c76a27027df3a671bf35ef1aa15e /apt-pkg/contrib/fileutl.cc | |
parent | 99016ee630714bf906b1f58f6a898226bce0bb03 (diff) | |
parent | 662603c40b8b38e487f76e7aceb773c935203cea (diff) |
merged from debian-experimental-ma0.8.0
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 2a3b8a87d..91aecee65 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -669,7 +669,7 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms) } break; - case WriteEmpty: + case WriteAtomic: { Flags |= Replace; char *name = strdup((FileName + ".XXXXXX").c_str()); @@ -678,6 +678,15 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms) free(name); break; } + + case WriteEmpty: + { + struct stat Buf; + if (lstat(FileName.c_str(),&Buf) == 0 && S_ISLNK(Buf.st_mode)) + unlink(FileName.c_str()); + iFd = open(FileName.c_str(),O_RDWR | O_CREAT | O_TRUNC,Perms); + break; + } case WriteExists: iFd = open(FileName.c_str(),O_RDWR); |