Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / bfdio.c
index 71ac17ec51515e157214769d8efb5fc45971d3df..29834d9c6b69e017225c533b2c29f64f99b949a2 100644 (file)
@@ -26,6 +26,9 @@
 #include "bfd.h"
 #include "libbfd.h"
 #include "aout/ar.h"
+#if defined (_WIN32)
+#include <windows.h>
+#endif
 
 #ifndef S_IXUSR
 #define S_IXUSR 0100    /* Execute by owner.  */
@@ -93,12 +96,7 @@ _bfd_real_fopen (const char *filename, const char *modes)
      In fopen-vms.h, they are separated from the mode with a comma.
      Split here.  */
   vms_attr = strchr (modes, ',');
-  if (vms_attr == NULL)
-    {
-      /* No attributes.  */
-      return close_on_exec (fopen (filename, modes));
-    }
-  else
+  if (vms_attr != NULL)
     {
       /* Attributes found.  Split.  */
       size_t modes_len = strlen (modes) + 1;
@@ -116,13 +114,29 @@ _bfd_real_fopen (const char *filename, const char *modes)
        }
       return close_on_exec (fopen (filename, at[0], at[1], at[2]));
     }
-#else /* !VMS */
-#if defined (HAVE_FOPEN64)
+
+#elif defined (_WIN32)
+  size_t filelen = strlen (filename) + 1;
+
+  if (filelen > MAX_PATH - 1)
+    {
+      FILE *file;
+      char* fullpath = (char *) malloc (filelen + 8);
+
+      /* Add a Microsoft recommended prefix that
+        will allow the extra-long path to work.  */
+      strcpy (fullpath, "\\\\?\\");
+      strcat (fullpath, filename);
+      file = close_on_exec (fopen (fullpath, modes));
+      free (fullpath);
+      return file;
+    }
+
+#elif defined (HAVE_FOPEN64)
   return close_on_exec (fopen64 (filename, modes));
-#else
-  return close_on_exec (fopen (filename, modes));
 #endif
-#endif /* !VMS */
+
+  return close_on_exec (fopen (filename, modes));
 }
 
 /*
@@ -187,6 +201,7 @@ bfd_bread (void *ptr, bfd_size_type size, bfd *abfd)
       offset += abfd->origin;
       abfd = abfd->my_archive;
     }
+  offset += abfd->origin;
 
   /* If this is an archive element, don't read past the end of
      this element.  */
@@ -256,6 +271,7 @@ bfd_tell (bfd *abfd)
       offset += abfd->origin;
       abfd = abfd->my_archive;
     }
+  offset += abfd->origin;
 
   if (abfd->iovec == NULL)
     return 0;
@@ -316,6 +332,7 @@ bfd_seek (bfd *abfd, file_ptr position, int direction)
       offset += abfd->origin;
       abfd = abfd->my_archive;
     }
+  offset += abfd->origin;
 
   if (abfd->iovec == NULL)
     {
@@ -508,6 +525,7 @@ bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
       offset += abfd->origin;
       abfd = abfd->my_archive;
     }
+  offset += abfd->origin;
 
   if (abfd->iovec == NULL)
     {
This page took 0.038366 seconds and 4 git commands to generate.