[devel] [PATCH for apt 27/38] FileFd: all files are closed automatically

Aleksei Nikiforov darktemplar на altlinux.org
Вт Дек 10 18:23:32 MSK 2019


Remove unused API
---
 apt/apt-pkg/contrib/fileutl.cc | 4 +---
 apt/apt-pkg/contrib/fileutl.h  | 8 +++++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/apt/apt-pkg/contrib/fileutl.cc b/apt/apt-pkg/contrib/fileutl.cc
index abcf363..38a28ec 100644
--- a/apt/apt-pkg/contrib/fileutl.cc
+++ b/apt/apt-pkg/contrib/fileutl.cc
@@ -682,7 +682,6 @@ bool ExecWait(int Pid,const char *Name,bool Reap)
 bool FileFd::Open(const string &FileName,OpenMode Mode, unsigned long Perms)
 {
    Close();
-   Flags = AutoClose;
    switch (Mode)
    {
       case ReadOnly:
@@ -872,8 +871,7 @@ unsigned long long FileFd::Size()
 bool FileFd::Close()
 {
    bool Res = true;
-   if ((Flags & AutoClose) == AutoClose)
-      if (iFd >= 0 && close(iFd) != 0)
+   if (iFd >= 0 && close(iFd) != 0)
 	 Res &= _error->Errno("close",_("Problem closing the file"));
    iFd = -1;
    
diff --git a/apt/apt-pkg/contrib/fileutl.h b/apt/apt-pkg/contrib/fileutl.h
index 770d3bb..04229c8 100644
--- a/apt/apt-pkg/contrib/fileutl.h
+++ b/apt/apt-pkg/contrib/fileutl.h
@@ -34,7 +34,7 @@ class FileFd
    protected:
    int iFd;
  
-   enum LocalFlags {AutoClose = (1<<0),Fail = (1<<1),DelOnFail = (1<<2),
+   enum LocalFlags {Fail = (1<<1),DelOnFail = (1<<2),
                     HitEof = (1<<3)};
    unsigned long Flags;
    string FileName;
@@ -75,9 +75,11 @@ class FileFd
    {
       Open(FileName,Mode,Perms);
    };
-   FileFd(int Fd = -1) : iFd(Fd), Flags(AutoClose) {};
-   FileFd(int Fd,bool) : iFd(Fd), Flags(0) {};
+   FileFd(int Fd = -1) : iFd(Fd), Flags(0) {};
    virtual ~FileFd();
+
+   FileFd(const FileFd &other) = delete;
+   FileFd& operator=(const FileFd &other) = delete;
 };
 
 bool CopyFile(FileFd &From,FileFd &To);
-- 
2.24.0



Подробная информация о списке рассылки Devel