// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: fileutl.cc,v 1.1 1998/07/02 02:58:13 jgg Exp $
+// $Id: fileutl.cc,v 1.5 1998/07/15 05:56:43 jgg Exp $
/* ######################################################################
File Utilities
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include <fileutl.h>
-#include <pkglib/error.h>
+#ifdef __GNUG__
+#pragma implementation "apt-pkg/fileutl.h"
+#endif
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/error.h>
#include <unistd.h>
#include <sys/stat.h>
/* 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:
{
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)