summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/fileutl.cc18
-rw-r--r--apt-pkg/contrib/fileutl.h9
2 files changed, 16 insertions, 11 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 43717da16..4374dd7d5 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.27 1999/04/20 05:02:09 jgg Exp $
+// $Id: fileutl.cc,v 1.28 1999/07/11 22:42:32 jgg Exp $
/* ######################################################################
File Utilities
@@ -250,11 +250,12 @@ int ExecFork()
}
/*}}}*/
-// FileFd::FileFd - Open a file /*{{{*/
+// FileFd::Open - Open a file /*{{{*/
// ---------------------------------------------------------------------
/* The most commonly used open mode combinations are given with Mode */
-FileFd::FileFd(string FileName,OpenMode Mode, unsigned long Perms)
+bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms)
{
+ Close();
Flags = AutoClose;
switch (Mode)
{
@@ -281,12 +282,11 @@ FileFd::FileFd(string FileName,OpenMode Mode, unsigned long Perms)
}
if (iFd < 0)
- _error->Errno("open","Could not open file %s",FileName.c_str());
- else
- {
- this->FileName = FileName;
- SetCloseExec(iFd,true);
- }
+ return _error->Errno("open","Could not open file %s",FileName.c_str());
+
+ this->FileName = FileName;
+ SetCloseExec(iFd,true);
+ return true;
}
/*}}}*/
// FileFd::~File - Closes the file /*{{{*/
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 8a1083241..e24f9cfb6 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: fileutl.h,v 1.18 1999/04/20 05:02:09 jgg Exp $
+// $Id: fileutl.h,v 1.19 1999/07/11 22:42:32 jgg Exp $
/* ######################################################################
File Utilities
@@ -45,6 +45,7 @@ class FileFd
bool Truncate(unsigned long To);
unsigned long Tell();
unsigned long Size();
+ bool Open(string FileName,OpenMode Mode,unsigned long Perms = 0666);
bool Close();
// Simple manipulators
@@ -56,7 +57,11 @@ class FileFd
inline void OpFail() {Flags |= Fail;};
inline string &Name() {return FileName;};
- FileFd(string FileName,OpenMode Mode,unsigned long Perms = 0666);
+ FileFd(string FileName,OpenMode Mode,unsigned long Perms = 0666) : iFd(-1),
+ Flags(0)
+ {
+ Open(FileName,Mode,Perms);
+ };
FileFd(int Fd = -1) : iFd(Fd), Flags(AutoClose) {};
FileFd(int Fd,bool) : iFd(Fd), Flags(0) {};
virtual ~FileFd();