]> git.saurik.com Git - apt.git/commitdiff
new tempfile writing mode (WriteTemp) for FileFd class
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:56:53 +0000 (16:56 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:56:53 +0000 (16:56 +0000)
Author: tausq
Date: 2001-03-03 22:36:20 GMT
new tempfile writing mode (WriteTemp) for FileFd class

apt-pkg/contrib/fileutl.cc
apt-pkg/contrib/fileutl.h

index 0907f4dcd3650a585833b505bb387f67d1688bce..fd9b93036985698246f427d772443574e433dc76 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: fileutl.cc,v 1.35 2001/02/20 07:03:17 jgg Exp $
+// $Id: fileutl.cc,v 1.36 2001/03/03 22:36:20 tausq Exp $
 /* ######################################################################
    
    File Utilities
@@ -403,6 +403,11 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms)
       case WriteAny:
       iFd = open(FileName.c_str(),O_RDWR | O_CREAT,Perms);
       break;      
+
+      case WriteTemp:
+      unlink(Filename.c_str());
+      iFd = open(FileName.c_str(),O_RDWR | O_CREATE | O_EXCL,Perms);
+      break;
    }  
 
    if (iFd < 0)
index 9cf351d0b29908aa010e8cc452ed10da4811b1f6..74e0d542f9d9ca2b9fd9875580e0ab5afa0c9a6d 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: fileutl.h,v 1.23 2001/02/20 07:03:17 jgg Exp $
+// $Id: fileutl.h,v 1.24 2001/03/03 22:36:20 tausq Exp $
 /* ######################################################################
    
    File Utilities
@@ -38,7 +38,7 @@ class FileFd
    string FileName;
    
    public:
-   enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny};
+   enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp};
    
    bool Read(void *To,unsigned long Size,bool AllowEof = false);
    bool Write(const void *From,unsigned long Size);