]> git.saurik.com Git - apt.git/commitdiff
Revert "if the FileFd failed already following calls should fail, too"
authorJulian Andres Klode <jak@debian.org>
Mon, 14 Nov 2016 15:24:25 +0000 (16:24 +0100)
committerJulian Andres Klode <jak@debian.org>
Mon, 14 Nov 2016 15:24:25 +0000 (16:24 +0100)
This reverts commit 1b63558a39ee1eed7eb024cd0e164d73beb165b1.

This commit caused a regression in the unit tests: The error was
propagated to Close(), where we expected it to return true.

apt-pkg/contrib/fileutl.cc

index df39ae16004866f72cffaa33ea09d3bd2e9f71fc..fbf0778418f6363c0037c182f201d2928ff743f7 100644 (file)
@@ -2376,7 +2376,7 @@ FileFd::~FileFd()
    gracefully. */
 bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
 {
-   if (d == nullptr || Failed())
+   if (d == nullptr)
       return false;
    ssize_t Res = 1;
    errno = 0;
@@ -2427,7 +2427,7 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
 char* FileFd::ReadLine(char *To, unsigned long long const Size)
 {
    *To = '\0';
-   if (d == nullptr || Failed())
+   if (d == nullptr)
       return nullptr;
    return d->InternalReadLine(To, Size);
 }
@@ -2435,8 +2435,6 @@ char* FileFd::ReadLine(char *To, unsigned long long const Size)
 // FileFd::Flush - Flush the file                                      /*{{{*/
 bool FileFd::Flush()
 {
-   if (Failed())
-      return false;
    if (d == nullptr)
       return true;
 
@@ -2446,7 +2444,7 @@ bool FileFd::Flush()
 // FileFd::Write - Write to the file                                   /*{{{*/
 bool FileFd::Write(const void *From,unsigned long long Size)
 {
-   if (d == nullptr || Failed())
+   if (d == nullptr)
       return false;
    ssize_t Res = 1;
    errno = 0;
@@ -2502,7 +2500,7 @@ bool FileFd::Write(int Fd, const void *From, unsigned long long Size)
 // FileFd::Seek - Seek in the file                                     /*{{{*/
 bool FileFd::Seek(unsigned long long To)
 {
-   if (d == nullptr || Failed())
+   if (d == nullptr)
       return false;
    Flags &= ~HitEof;
    return d->InternalSeek(To);
@@ -2511,7 +2509,7 @@ bool FileFd::Seek(unsigned long long To)
 // FileFd::Skip - Skip over data in the file                           /*{{{*/
 bool FileFd::Skip(unsigned long long Over)
 {
-   if (d == nullptr || Failed())
+   if (d == nullptr)
       return false;
    return d->InternalSkip(Over);
 }
@@ -2519,7 +2517,7 @@ bool FileFd::Skip(unsigned long long Over)
 // FileFd::Truncate - Truncate the file                                        /*{{{*/
 bool FileFd::Truncate(unsigned long long To)
 {
-   if (d == nullptr || Failed())
+   if (d == nullptr)
       return false;
    // truncating /dev/null is always successful - as we get an error otherwise
    if (To == 0 && FileName == "/dev/null")
@@ -2532,7 +2530,7 @@ bool FileFd::Truncate(unsigned long long To)
 /* */
 unsigned long long FileFd::Tell()
 {
-   if (d == nullptr || Failed())
+   if (d == nullptr)
       return false;
    off_t const Res = d->InternalTell();
    if (Res == (off_t)-1)
@@ -2595,7 +2593,7 @@ time_t FileFd::ModificationTime()
 unsigned long long FileFd::Size()
 {
    if (d == nullptr)
-      return 0;
+      return false;
    return d->InternalSize();
 }
                                                                        /*}}}*/