From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.1 From: Aleksei Nikiforov To: devel@lists.altlinux.org Date: Tue, 10 Dec 2019 18:23:32 +0300 Message-Id: <20191210152343.33867-28-darktemplar@altlinux.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191210152343.33867-1-darktemplar@altlinux.org> References: <20191210152343.33867-1-darktemplar@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: Aleksei Nikiforov Subject: [devel] [PATCH for apt 27/38] FileFd: all files are closed automatically X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Dec 2019 15:25:09 -0000 Archived-At: List-Archive: List-Post: 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