]> 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 6a621e2a9d9d987d4b23be82f995ac5ab6a8bd21..85dc6f6006a7ed963dd017459b8c19e65bf442ac 100644 (file)
 #include <errno.h>
 #include <set>
 #include <algorithm>
+
+#include <config.h>
+#ifdef WORDS_BIGENDIAN
+#include <inttypes.h>
+#endif
                                                                        /*}}}*/
 
 using namespace std;
@@ -62,6 +67,15 @@ bool RunScripts(const char *Cnf)
    // This is the child
    if (Child == 0)
    {
+      if (_config->FindDir("DPkg::Chroot-Directory","/") != "/") 
+      {
+         std::cerr << "Chrooting into " 
+                   << _config->FindDir("DPkg::Chroot-Directory") 
+                   << std::endl;
+         if (chroot(_config->FindDir("DPkg::Chroot-Directory","/").c_str()) != 0)
+            _exit(100);
+      }
+
       if (chdir("/tmp/") != 0)
         _exit(100);
         
@@ -432,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                    /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -967,8 +992,10 @@ unsigned long FileFd::Size()
           return _error->Errno("read","Unable to read original size of gzipped file");
 
 #ifdef WORDS_BIGENDIAN
-       unsigned char const * const p = (unsigned char *) &size;
-       size = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
+       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)