summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-08-24 16:34:12 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-08-24 16:34:12 +0200
commit7c122f33c4bf8caec1cf8b250d512b65c3c574ca (patch)
tree81786b34b546c76a27027df3a671bf35ef1aa15e /apt-pkg/contrib
parent99016ee630714bf906b1f58f6a898226bce0bb03 (diff)
parent662603c40b8b38e487f76e7aceb773c935203cea (diff)
merged from debian-experimental-ma0.8.0
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/fileutl.cc11
-rw-r--r--apt-pkg/contrib/fileutl.h3
-rw-r--r--apt-pkg/contrib/strutl.cc2
3 files changed, 13 insertions, 3 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);
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 62705478d..cb4655798 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -46,7 +46,8 @@ class FileFd
gzFile gz;
public:
- enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp,ReadOnlyGzip};
+ enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp,ReadOnlyGzip,
+ WriteAtomic};
inline bool Read(void *To,unsigned long Size,bool AllowEof)
{
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index ace74cb37..c1844de40 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1161,7 +1161,7 @@ void strprintf(string &out,const char *format,...)
char *safe_snprintf(char *Buffer,char *End,const char *Format,...)
{
va_list args;
- unsigned long Did;
+ int Did;
va_start(args,Format);