Lines Matching refs:abfd

49 cache_btell (struct bfd *abfd)
51 return real_ftell (bfd_cache_lookup (abfd));
55 cache_bseek (struct bfd *abfd, file_ptr offset, int whence)
57 return real_fseek (bfd_cache_lookup (abfd), offset, whence);
68 cache_bread (struct bfd *abfd, void *buf, file_ptr nbytes)
86 nread = read (fileno (bfd_cache_lookup (abfd)), buf, nbytes);
96 nread = fread (buf, 1, nbytes, bfd_cache_lookup (abfd));
100 if (nread < nbytes && ferror (bfd_cache_lookup (abfd)))
110 cache_bwrite (struct bfd *abfd, const void *where, file_ptr nbytes)
112 file_ptr nwrite = fwrite (where, 1, nbytes, bfd_cache_lookup (abfd));
113 if (nwrite < nbytes && ferror (bfd_cache_lookup (abfd)))
122 cache_bclose (struct bfd *abfd)
124 return bfd_cache_close (abfd);
128 cache_bflush (struct bfd *abfd)
130 int sts = fflush (bfd_cache_lookup (abfd));
137 cache_bstat (struct bfd *abfd, struct stat *sb)
139 int sts = fstat (fileno (bfd_cache_lookup (abfd)), sb);
201 insert (bfd *abfd)
205 abfd->lru_next = abfd;
206 abfd->lru_prev = abfd;
210 abfd->lru_next = bfd_last_cache;
211 abfd->lru_prev = bfd_last_cache->lru_prev;
212 abfd->lru_prev->lru_next = abfd;
213 abfd->lru_next->lru_prev = abfd;
215 bfd_last_cache = abfd;
221 snip (bfd *abfd)
223 abfd->lru_prev->lru_next = abfd->lru_next;
224 abfd->lru_next->lru_prev = abfd->lru_prev;
225 if (abfd == bfd_last_cache)
227 bfd_last_cache = abfd->lru_next;
228 if (abfd == bfd_last_cache)
271 bfd_cache_delete (bfd *abfd)
275 if (fclose ((FILE *) abfd->iostream) == 0)
283 snip (abfd);
285 abfd->iostream = NULL;
296 bfd_boolean bfd_cache_init (bfd *abfd);
303 bfd_cache_init (bfd *abfd)
305 BFD_ASSERT (abfd->iostream != NULL);
311 abfd->iovec = &cache_iovec;
312 insert (abfd);
322 bfd_boolean bfd_cache_close (bfd *abfd);
325 Remove the BFD @var{abfd} from the cache. If the attached file is open,
334 bfd_cache_close (bfd *abfd)
336 if (abfd->iovec != &cache_iovec)
339 if (abfd->iostream == NULL)
343 return bfd_cache_delete (abfd);
378 FILE* bfd_open_file (bfd *abfd);
381 Call the OS to open a file for @var{abfd}. Return the <<FILE *>>
389 bfd_open_file (bfd *abfd)
391 abfd->cacheable = TRUE; /* Allow it to be closed later. */
399 switch (abfd->direction)
403 abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RB);
407 if (abfd->opened_once)
409 abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RUB);
410 if (abfd->iostream == NULL)
411 abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WUB);
438 if (stat (abfd->filename, &s) == 0 && s.st_size != 0)
439 unlink (abfd->filename);
441 abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WUB);
442 abfd->opened_once = TRUE;
447 if (abfd->iostream != NULL)
449 if (! bfd_cache_init (abfd))
453 return (FILE *) abfd->iostream;
461 FILE *bfd_cache_lookup_worker (bfd *abfd);
465 quick answer. Find a file descriptor for @var{abfd}. If
469 returning NULL if it is unable to (re)open the @var{abfd}.
473 bfd_cache_lookup_worker (bfd *abfd)
475 if ((abfd->flags & BFD_IN_MEMORY) != 0)
478 if (abfd->my_archive)
479 abfd = abfd->my_archive;
481 if (abfd->iostream != NULL)
484 if (abfd != bfd_last_cache)
486 snip (abfd);
487 insert (abfd);
492 if (bfd_open_file (abfd) == NULL
493 || abfd->where != (unsigned long) abfd->where
494 || real_fseek ((FILE *) abfd->iostream, abfd->where, SEEK_SET) != 0)
498 return (FILE *) abfd->iostream;