summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc11
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);