]> git.saurik.com Git - apt.git/commitdiff
* apt-pkg/contrib/fileutl.{h,cc}:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 10 Dec 2011 19:03:49 +0000 (20:03 +0100)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 10 Dec 2011 19:03:49 +0000 (20:03 +0100)
  - implement a ModificationTime method for FileFd

apt-pkg/contrib/fileutl.cc
apt-pkg/contrib/fileutl.h
apt-pkg/deb/debindexfile.cc
apt-pkg/edsp/edspindexfile.cc
debian/changelog

index 1cb3fab1e5a55f292f0d954f09eddfad1118025a..83b68e796f310ed21386d394a8707e11b3abfbe1 100644 (file)
@@ -1106,6 +1106,20 @@ unsigned long long FileFd::Size()
    return size;
 }
                                                                        /*}}}*/
    return size;
 }
                                                                        /*}}}*/
+// FileFd::ModificationTime - Return the time of last touch            /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+time_t FileFd::ModificationTime()
+{
+   struct stat Buf;
+   if (fstat(iFd,&Buf) != 0)
+   {
+      _error->Errno("fstat","Unable to determine the modification time of file %s", FileName.c_str());
+      return 0;
+   }
+   return Buf.st_mtime;
+}
+                                                                       /*}}}*/
 // FileFd::Close - Close the file if the close flag is set             /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 // FileFd::Close - Close the file if the close flag is set             /*{{{*/
 // ---------------------------------------------------------------------
 /* */
index 59a9d97e3995367213a6ed29c4cd0ede4fccc6ad..8f2d7a0a04948e537731b62e2c442cafc6bbf040 100644 (file)
@@ -78,6 +78,7 @@ class FileFd
    unsigned long long Tell();
    unsigned long long Size();
    unsigned long long FileSize();
    unsigned long long Tell();
    unsigned long long Size();
    unsigned long long FileSize();
+   time_t ModificationTime();
 
    /* You want to use 'unsigned long long' if you are talking about a file
       to be able to support large files (>2 or >4 GB) properly.
 
    /* You want to use 'unsigned long long' if you are talking about a file
       to be able to support large files (>2 or >4 GB) properly.
index d9c448598ab879f3dd25605dc42dd310f6b77d92..2635d52c8d215874c2b77e3973fc495bb39e7ebf 100644 (file)
@@ -319,12 +319,8 @@ bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
    // Store the IMS information
    pkgCache::PkgFileIterator File = Gen.GetCurFile();
    pkgCacheGenerator::Dynamic<pkgCache::PkgFileIterator> DynFile(File);
    // Store the IMS information
    pkgCache::PkgFileIterator File = Gen.GetCurFile();
    pkgCacheGenerator::Dynamic<pkgCache::PkgFileIterator> DynFile(File);
-   // FIXME: Get this info from FileFd instead
-   struct stat St;
-   if (fstat(Pkg.Fd(),&St) != 0)
-      return _error->Errno("fstat","Failed to stat");
-   File->Size = St.st_size;
-   File->mtime = St.st_mtime;
+   File->Size = Pkg.FileSize();
+   File->mtime = Pkg.ModificationTime();
    
    if (Gen.MergeList(Parser) == false)
       return _error->Error("Problem with MergeList %s",PackageFile.c_str());
    
    if (Gen.MergeList(Parser) == false)
       return _error->Error("Problem with MergeList %s",PackageFile.c_str());
@@ -522,11 +518,8 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
 
      // Store the IMS information
      pkgCache::PkgFileIterator TransFile = Gen.GetCurFile();
 
      // Store the IMS information
      pkgCache::PkgFileIterator TransFile = Gen.GetCurFile();
-     struct stat TransSt;
-     if (fstat(Trans.Fd(),&TransSt) != 0)
-       return _error->Errno("fstat","Failed to stat");
-     TransFile->Size = TransSt.st_size;
-     TransFile->mtime = TransSt.st_mtime;
+     TransFile->Size = Trans.FileSize();
+     TransFile->mtime = Trans.ModificationTime();
    
      if (Gen.MergeList(TransParser) == false)
        return _error->Error("Problem with MergeList %s",TranslationFile.c_str());
    
      if (Gen.MergeList(TransParser) == false)
        return _error->Error("Problem with MergeList %s",TranslationFile.c_str());
@@ -608,8 +601,8 @@ bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
    struct stat St;
    if (fstat(Pkg.Fd(),&St) != 0)
       return _error->Errno("fstat","Failed to stat");
    struct stat St;
    if (fstat(Pkg.Fd(),&St) != 0)
       return _error->Errno("fstat","Failed to stat");
-   CFile->Size = St.st_size;
-   CFile->mtime = St.st_mtime;
+   CFile->Size = Pkg.FileSize();
+   CFile->mtime = Pkg.ModificationTime();
    CFile->Archive = Gen.WriteUniqString("now");
    
    if (Gen.MergeList(Parser) == false)
    CFile->Archive = Gen.WriteUniqString("now");
    
    if (Gen.MergeList(Parser) == false)
index 058cef63689ba80356187fa9e90b69a7b9a4f358..5d824f9cb8156cad3c30a767e2174e4a2ff4d173 100644 (file)
@@ -49,11 +49,8 @@ bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
 
    // Store the IMS information
    pkgCache::PkgFileIterator CFile = Gen.GetCurFile();
 
    // Store the IMS information
    pkgCache::PkgFileIterator CFile = Gen.GetCurFile();
-   struct stat St;
-   if (fstat(Pkg.Fd(),&St) != 0)
-      return _error->Errno("fstat","Failed to stat");
-   CFile->Size = St.st_size;
-   CFile->mtime = St.st_mtime;
+   CFile->Size = Pkg.FileSize();
+   CFile->mtime = Pkg.ModificationTime();
    CFile->Archive = Gen.WriteUniqString("edsp::scenario");
 
    if (Gen.MergeList(Parser) == false)
    CFile->Archive = Gen.WriteUniqString("edsp::scenario");
 
    if (Gen.MergeList(Parser) == false)
index 685774a8f1ee7113fb36f00c35f79e51837951aa..a401d61a0ae54f86b61d444ae96fb617508b9bab 100644 (file)
@@ -1,4 +1,3 @@
-
 apt (0.8.16~exp9) UNRELEASED; urgency=low
 
   [ Julian Andres Klode ]
 apt (0.8.16~exp9) UNRELEASED; urgency=low
 
   [ Julian Andres Klode ]
@@ -30,8 +29,10 @@ apt (0.8.16~exp9) UNRELEASED; urgency=low
       resolver as it's basically the same for the user, so no need to choose
   * cmdline/apt-config.cc:
     - dump the APT::Compressor settings correctly and completely
       resolver as it's basically the same for the user, so no need to choose
   * cmdline/apt-config.cc:
     - dump the APT::Compressor settings correctly and completely
+  * apt-pkg/contrib/fileutl.{h,cc}:
+    - implement a ModificationTime method for FileFd
 
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 10 Dec 2011 17:34:50 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 10 Dec 2011 20:02:29 +0100
 
 apt (0.8.16~exp8) experimental; urgency=low
 
 
 apt (0.8.16~exp8) experimental; urgency=low