daily update
[deliverable/binutils-gdb.git] / bfd / cache.c
index 58eda916bbc9052263f6e40527d0d0c5dab5502c..163fa2bb2666af88f3513cce9e6d9ebbfe884609 100644 (file)
@@ -19,7 +19,7 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 /*
 SECTION
@@ -41,6 +41,7 @@ SECTION
 #include "bfd.h"
 #include "sysdep.h"
 #include "libbfd.h"
+#include "libiberty.h"
 
 static bfd_boolean bfd_cache_delete (bfd *);
 
@@ -343,6 +344,33 @@ bfd_cache_close (bfd *abfd)
   return bfd_cache_delete (abfd);
 }
 
+/*
+FUNCTION
+       bfd_cache_close_all
+
+SYNOPSIS
+       bfd_boolean bfd_cache_close_all (void);
+
+DESCRIPTION
+       Remove all BFDs from the cache. If the attached file is open,
+       then close it too.
+
+RETURNS
+       <<FALSE>> is returned if closing one of the file fails, <<TRUE>> is
+       returned if all is well.
+*/
+
+bfd_boolean
+bfd_cache_close_all ()
+{
+  bfd_boolean ret = TRUE;
+
+  while (bfd_last_cache != NULL)
+    ret &= bfd_cache_close (bfd_last_cache);
+
+  return ret;
+}
+
 /*
 INTERNAL_FUNCTION
        bfd_open_file
@@ -409,7 +437,7 @@ bfd_open_file (bfd *abfd)
          struct stat s;
 
          if (stat (abfd->filename, &s) == 0 && s.st_size != 0)
-           unlink (abfd->filename);
+           unlink_if_ordinary (abfd->filename);
 #endif
          abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WUB);
          abfd->opened_once = TRUE;
This page took 0.023794 seconds and 4 git commands to generate.