]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/fileutl.cc
apt-pkg/pkgcachegen.cc: fix compiler error
[apt.git] / apt-pkg / contrib / fileutl.cc
index 935c4bebfdf0909f9184168a75f3f21e7cf59a02..85dc6f6006a7ed963dd017459b8c19e65bf442ac 100644 (file)
 #include <errno.h>
 #include <set>
 #include <algorithm>
+
+#include <config.h>
+#ifdef WORDS_BIGENDIAN
+#include <inttypes.h>
+#endif
                                                                        /*}}}*/
 
 using namespace std;
@@ -441,6 +446,17 @@ string SafeGetCWD()
    return S;
 }
                                                                        /*}}}*/
+// GetModificationTime - Get the mtime of the given file or -1 on error /*{{{*/
+// ---------------------------------------------------------------------
+/* We return / on failure. */
+time_t GetModificationTime(string const &Path)
+{
+   struct stat St;
+   if (stat(Path.c_str(), &St) < 0)
+      return -1;
+   return  St.st_mtime;
+}
+                                                                       /*}}}*/
 // flNotDir - Strip the directory from the filename                    /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -971,9 +987,16 @@ unsigned long FileFd::Size()
        off_t orig_pos = lseek(iFd, 0, SEEK_CUR);
        if (lseek(iFd, -4, SEEK_END) < 0)
           return _error->Errno("lseek","Unable to seek to end of gzipped file");
+       size = 0L;
        if (read(iFd, &size, 4) != 4)
           return _error->Errno("read","Unable to read original size of gzipped file");
-       size &= 0xFFFFFFFF;
+
+#ifdef WORDS_BIGENDIAN
+       uint32_t tmp_size = size;
+       uint8_t const * const p = (uint8_t const * const) &tmp_size;
+       tmp_size = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
+       size = tmp_size;
+#endif
 
        if (lseek(iFd, orig_pos, SEEK_SET) < 0)
           return _error->Errno("lseek","Unable to seek in gzipped file");