summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:51:43 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:51:43 +0000
commit50b513a12b4f9f5098d1bcd08f6b19b7693397d0 (patch)
treedb7b9bf832d1e76fab1bd966a5eaf56c8c9a6c32 /apt-pkg/contrib
parent83d89a9f6a641adccce898eb0bc675d94bc46465 (diff)
Fixes for file opening
Author: jgg Date: 1998-11-27 04:20:52 GMT Fixes for file opening
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/fileutl.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index b5cdf782b..379641c2c 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: fileutl.cc,v 1.15 1998/11/27 01:14:08 jgg Exp $
+// $Id: fileutl.cc,v 1.16 1998/11/27 04:20:52 jgg Exp $
/* ######################################################################
File Utilities
@@ -186,9 +186,13 @@ FileFd::FileFd(string FileName,OpenMode Mode, unsigned long Perms)
break;
case WriteEmpty:
- unlink(FileName.c_str());
- iFd = open(FileName.c_str(),O_RDWR | O_CREAT | O_EXCL,Perms);
- break;
+ {
+ struct stat Buf;
+ if (stat(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);