Browse Source

Use a pure file descriptor, instead of a stream, to load the data, in
ensure_packagefiles_available.

Adam Heath 25 years ago
parent
commit
9b62bef082
2 changed files with 13 additions and 8 deletions
  1. 5 0
      ChangeLog
  2. 8 8
      main/filesdb.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+Sat Mar 10 15:59:39 CST 2001 Adam Heath <doogie@debian.org>
+
+  * main/filesdb.c: Use a pure file descriptor, instead of a stream, to
+    load the data, in ensure_packagefiles_available.
+
 Sat Mar 10 01:33:15 CET 2001 Wichert Akkerman <wakkerma@debian.org>
 
   * main/main,h, main/main.c: add --no-debsig option using f_nodebsign

+ 8 - 8
main/filesdb.c

@@ -60,7 +60,7 @@ static int saidread=0;
 void ensure_packagefiles_available(struct pkginfo *pkg) {
   static struct varbuf fnvb;
   
-  FILE *file;
+  int fd;
   const char *filelistfile;
   struct fileinlist **lendp, *newent, *current;
   struct filepackages *packageslump;
@@ -118,9 +118,9 @@ void ensure_packagefiles_available(struct pkginfo *pkg) {
 
   onerr_abort++;
   
-  file= fopen(filelistfile,"r");
+  fd= open(filelistfile,O_RDONLY);
 
-  if (!file) {
+  if (fd==-1) {
     if (errno != ENOENT)
       ohshite(_("unable to open files list file for package `%.250s'"),pkg->name);
     onerr_abort--;
@@ -135,14 +135,14 @@ void ensure_packagefiles_available(struct pkginfo *pkg) {
     return;
   }
 
-  push_cleanup(cu_closefile,ehflag_bombout, 0,0, 1,(void*)file);
+  push_cleanup(cu_closefd,ehflag_bombout, 0,0, 1,(void*)fd);
   
-   if(fstat(fileno(file), &stat_buf))
+   if(fstat(fd, &stat_buf))
      ohshite("unable to stat files list file for package `%.250s'",pkg->name);
    loaded_list = nfmalloc(stat_buf.st_size);
    loaded_list_end = loaded_list + stat_buf.st_size;
 
-  fd_buf_copy(fileno(file), loaded_list, stat_buf.st_size, _("files list for package `%.250s'"), pkg->name);
+  fd_buf_copy(fd, loaded_list, stat_buf.st_size, _("files list for package `%.250s'"), pkg->name);
 
   lendp= &pkg->clientdata->files;
   thisline = loaded_list;
@@ -164,8 +164,8 @@ void ensure_packagefiles_available(struct pkginfo *pkg) {
     lendp= &newent->next;
     thisline = nextline;
   }
-  pop_cleanup(ehflag_normaltidy); /* file= fopen() */
-  if (fclose(file))
+  pop_cleanup(ehflag_normaltidy); /* fd= open() */
+  if (close(fd))
     ohshite(_("error closing files list file for package `%.250s'"),pkg->name);
   if (fnvb.used)
     ohshit(_("files list file for package `%.250s' is truncated"),pkg->name);