Change bfd_get_size/bfd_get_file_size to ufile_ptr
[deliverable/binutils-gdb.git] / bfd / bfdio.c
index 71991bd47eed3cbb1f08ea21eb3ab11b0d5d7ad3..fa7fb21c8c3612e5a9eb4c6707700be54b0061b3 100644 (file)
@@ -1,6 +1,6 @@
 /* Low-level I/O routines for BFDs.
 
-   Copyright (C) 1990-2016 Free Software Foundation, Inc.
+   Copyright (C) 1990-2017 Free Software Foundation, Inc.
 
    Written by Cygnus Support.
 
@@ -41,7 +41,7 @@
 #endif
 
 file_ptr
-real_ftell (FILE *file)
+_bfd_real_ftell (FILE *file)
 {
 #if defined (HAVE_FTELLO64)
   return ftello64 (file);
@@ -53,7 +53,7 @@ real_ftell (FILE *file)
 }
 
 int
-real_fseek (FILE *file, file_ptr offset, int whence)
+_bfd_real_fseek (FILE *file, file_ptr offset, int whence)
 {
 #if defined (HAVE_FSEEKO64)
   return fseeko64 (file, offset, whence);
@@ -82,7 +82,7 @@ close_on_exec (FILE *file)
 }
 
 FILE *
-real_fopen (const char *filename, const char *modes)
+_bfd_real_fopen (const char *filename, const char *modes)
 {
 #ifdef VMS
   char *vms_attr;
@@ -392,7 +392,7 @@ FUNCTION
        bfd_get_size
 
 SYNOPSIS
-       file_ptr bfd_get_size (bfd *abfd);
+       ufile_ptr bfd_get_size (bfd *abfd);
 
 DESCRIPTION
        Return the file size (as read from file system) for the file
@@ -420,7 +420,7 @@ DESCRIPTION
        size reasonable?".
 */
 
-file_ptr
+ufile_ptr
 bfd_get_size (bfd *abfd)
 {
   struct stat buf;
@@ -434,6 +434,29 @@ bfd_get_size (bfd *abfd)
   return buf.st_size;
 }
 
+/*
+FUNCTION
+       bfd_get_file_size
+
+SYNOPSIS
+       ufile_ptr bfd_get_file_size (bfd *abfd);
+
+DESCRIPTION
+       Return the file size (as read from file system) for the file
+       associated with BFD @var{abfd}.  It supports both normal files
+       and archive elements.
+
+*/
+
+ufile_ptr
+bfd_get_file_size (bfd *abfd)
+{
+  if (abfd->my_archive != NULL
+      && !bfd_is_thin_archive (abfd->my_archive))
+    return arelt_size (abfd);
+
+  return bfd_get_size (abfd);
+}
 
 /*
 FUNCTION
This page took 0.036854 seconds and 4 git commands to generate.