X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/6c139d6e362f04a1582e8a8f511f8aeab031fecf..ad00ae81eb9e1f5384f8fe32879d483c72bbdace:/apt-pkg/contrib/fileutl.cc diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 29b12bef1..6f515fd67 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.3 1998/07/07 04:17:12 jgg Exp $ +// $Id: fileutl.cc,v 1.5 1998/07/15 05:56:43 jgg Exp $ /* ###################################################################### File Utilities @@ -15,10 +15,10 @@ /*}}}*/ // Include Files /*{{{*/ #ifdef __GNUG__ -#pragma implementation "pkglib/fileutl.h" +#pragma implementation "apt-pkg/fileutl.h" #endif -#include -#include +#include +#include #include #include @@ -113,7 +113,7 @@ string SafeGetCWD() /* The most commonly used open mode combinations are given with Mode */ File::File(string FileName,OpenMode Mode, unsigned long Perms) { - Flags = 0; + Flags = AutoClose; switch (Mode) { case ReadOnly: @@ -205,9 +205,10 @@ bool File::Close() { bool Res = true; if ((Flags & AutoClose) == AutoClose) - if (close(iFd) != 0) + if (iFd >= 0 && close(iFd) != 0) Res &= _error->Errno("close","Problem closing the file"); - + iFd = -1; + if ((Flags & Fail) == Fail && (Flags & DelOnFail) == DelOnFail && FileName.empty() == false) if (unlink(FileName.c_str()) != 0)