瀏覽代碼

dpkg-deb: Use fd_fd_copy instead of stream_fd_copy

Avoid a usage of stdio based buffer I/O, to try to get rid of it at some
point in the future.
Guillem Jover 16 年之前
父節點
當前提交
20493d176d
共有 1 個文件被更改,包括 5 次插入 和 4 次删除
  1. 5 4
      dpkg-deb/info.c

+ 5 - 4
dpkg-deb/info.c

@@ -30,6 +30,7 @@
 #include <limits.h>
 #include <ctype.h>
 #include <string.h>
+#include <fcntl.h>
 #include <dirent.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -94,7 +95,7 @@ static void info_spew(const char *debar, const char *directory,
                       const char *const *argv) {
   const char *component;
   struct varbuf controlfile = VARBUF_INIT;
-  FILE *co;
+  int fd;
   int re= 0;
 
   while ((component = *argv++) != NULL) {
@@ -104,9 +105,9 @@ static void info_spew(const char *debar, const char *directory,
     varbufaddstr(&controlfile, component);
     varbufaddc(&controlfile, '\0');
 
-    co = fopen(controlfile.buf, "r");
-    if (co) {
-      stream_fd_copy(co, 1, -1, _("info_spew"));
+    fd = open(controlfile.buf, O_RDONLY);
+    if (fd >= 0) {
+      fd_fd_copy(fd, 1, -1, _("info_spew"));
     } else if (errno == ENOENT) {
       fprintf(stderr,
               _("dpkg-deb: `%.255s' contains no control component `%.255s'\n"),