diff options
author | Julian Andres Klode <jak@debian.org> | 2015-12-27 14:25:11 +0100 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2015-12-27 16:19:33 +0100 |
commit | 766761fd836d9e247daea924809965c21cc65dc7 (patch) | |
tree | 028937f4c1c39a7a0da6282b360777bbbf49fc02 /apt-pkg/contrib/fileutl.cc | |
parent | 1d68256d525234d4fef1bb050dc2165771cdf7e3 (diff) |
FildFd: Introduce a Flush() function and call it from Close()
The flush function can be used for buffered writers.
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 8fdd6a5dd..ecc8c83fd 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1055,6 +1055,10 @@ public: *To = '\0'; return InitialTo; } + virtual bool InternalFlush() + { + return true; + } virtual ssize_t InternalWrite(void const * const From, unsigned long long const Size) = 0; virtual bool InternalWriteError() { return filefd->FileFdErrno("write",_("Write error")); } virtual bool InternalSeek(unsigned long long const To) @@ -2070,6 +2074,15 @@ char* FileFd::ReadLine(char *To, unsigned long long const Size) return d->InternalReadLine(To, Size); } /*}}}*/ +// FileFd::Flush - Flush the file /*{{{*/ +bool FileFd::Flush() +{ + if (d == nullptr) + return true; + + return d->InternalFlush(); +} + /*}}}*/ // FileFd::Write - Write to the file /*{{{*/ bool FileFd::Write(const void *From,unsigned long long Size) { @@ -2223,6 +2236,8 @@ unsigned long long FileFd::Size() /* */ bool FileFd::Close() { + if (Flush() == false) + return false; if (iFd == -1) return true; |