]> git.saurik.com Git - apt.git/blobdiff - methods/rred.cc
all errors should be printed to stderr
[apt.git] / methods / rred.cc
index f7dac3c191f8a89f8038fbaabe52881fe19c3221..cabb3c456ae923b66ba3bb87e3afcf4e378a3865 100644 (file)
@@ -8,24 +8,24 @@
 #include <config.h>
 
 #include <apt-pkg/fileutl.h>
-#include <apt-pkg/mmap.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/acquire-method.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/hashes.h>
 #include <apt-pkg/configuration.h>
 
+#include <stddef.h>
+#include <iostream>
 #include <string>
 #include <list>
 #include <vector>
-#include <iterator>
 
-#include <fcntl.h>
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 
 #include <apti18n.h>
 
@@ -468,7 +468,7 @@ class Patch {
 
    void write_diff(FILE *f)
    {
-      size_t line = 0;
+      unsigned long long line = 0;
       std::list<struct Change>::reverse_iterator ch;
       for (ch = filechanges.rbegin(); ch != filechanges.rend(); ++ch) {
         line += ch->offset + ch->del_cnt;
@@ -481,11 +481,11 @@ class Patch {
         line -= ch->del_cnt;
         if (ch->add_cnt > 0) {
            if (ch->del_cnt == 0) {
-              fprintf(f, "%lua\n", line);
+              fprintf(f, "%llua\n", line);
            } else if (ch->del_cnt == 1) {
-              fprintf(f, "%luc\n", line+1);
+              fprintf(f, "%lluc\n", line+1);
            } else {
-              fprintf(f, "%lu,%luc\n", line+1, line+ch->del_cnt);
+              fprintf(f, "%llu,%lluc\n", line+1, line+ch->del_cnt);
            }
 
            mg_i = ch;
@@ -495,9 +495,9 @@ class Patch {
 
            fprintf(f, ".\n");
         } else if (ch->del_cnt == 1) {
-           fprintf(f, "%lud\n", line+1);
+           fprintf(f, "%llud\n", line+1);
         } else if (ch->del_cnt > 1) {
-           fprintf(f, "%lu,%lud\n", line+1, line+ch->del_cnt);
+           fprintf(f, "%llu,%llud\n", line+1, line+ch->del_cnt);
         }
         line -= ch->offset;
       }
@@ -597,12 +597,12 @@ class RredMethod : public pkgAcqMethod {
               stat(patch_name.c_str(), &bufpatch) != 0)
            return _error->Errno("stat", _("Failed to stat"));
 
-        struct timespec times[2];
+        struct timeval times[2];
         times[0].tv_sec = bufbase.st_atime;
         times[1].tv_sec = bufpatch.st_mtime;
-        times[0].tv_nsec = times[1].tv_nsec = 0;
-        if (utimensat(AT_FDCWD, Itm->DestFile.c_str(), times, 0) != 0)
-           return _error->Errno("utimensat",_("Failed to set modification time"));
+        times[0].tv_usec = times[1].tv_usec = 0;
+        if (utimes(Itm->DestFile.c_str(), times) != 0)
+           return _error->Errno("utimes",_("Failed to set modification time"));
 
         if (stat(Itm->DestFile.c_str(), &bufbase) != 0)
            return _error->Errno("stat", _("Failed to stat"));