summaryrefslogtreecommitdiff
path: root/gcc/ada/g-dirope.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/g-dirope.adb')
-rw-r--r--gcc/ada/g-dirope.adb22
1 files changed, 12 insertions, 10 deletions
diff --git a/gcc/ada/g-dirope.adb b/gcc/ada/g-dirope.adb
index dc6977596a5..5302969ac71 100644
--- a/gcc/ada/g-dirope.adb
+++ b/gcc/ada/g-dirope.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1998-2005, AdaCore --
+-- Copyright (C) 1998-2006, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -33,7 +33,6 @@
with Ada.Characters.Handling;
with Ada.Strings.Fixed;
-with Ada.Strings.Maps;
with Unchecked_Deallocation;
with Unchecked_Conversion;
@@ -187,6 +186,9 @@ package body GNAT.Directory_Operations is
Discard : Integer;
pragma Warnings (Off, Discard);
+ function closedir (directory : DIRs) return Integer;
+ pragma Import (C, closedir, "__gnat_closedir");
+
begin
if not Is_Open (Dir) then
raise Directory_Error;
@@ -625,6 +627,9 @@ package body GNAT.Directory_Operations is
(Dir : out Dir_Type;
Dir_Name : Dir_Name_Str)
is
+ function opendir (file_name : String) return DIRs;
+ pragma Import (C, opendir, "__gnat_opendir");
+
C_File_Name : constant String := Dir_Name & ASCII.NUL;
begin
@@ -647,7 +652,7 @@ package body GNAT.Directory_Operations is
Last : out Natural)
is
Filename_Addr : Address;
- Filename_Len : Integer;
+ Filename_Len : aliased Integer;
Buffer : array (0 .. Filename_Max + 12) of Character;
-- 12 is the size of the dirent structure (see dirent.h), without the
@@ -655,27 +660,24 @@ package body GNAT.Directory_Operations is
function readdir_gnat
(Directory : System.Address;
- Buffer : System.Address) return System.Address;
+ Buffer : System.Address;
+ Last : access Integer) return System.Address;
pragma Import (C, readdir_gnat, "__gnat_readdir");
- function strlen (S : Address) return Integer;
- pragma Import (C, strlen, "strlen");
-
begin
if not Is_Open (Dir) then
raise Directory_Error;
end if;
Filename_Addr :=
- readdir_gnat (System.Address (Dir.all), Buffer'Address);
+ readdir_gnat
+ (System.Address (Dir.all), Buffer'Address, Filename_Len'Access);
if Filename_Addr = System.Null_Address then
Last := 0;
return;
end if;
- Filename_Len := strlen (Filename_Addr);
-
if Str'Length > Filename_Len then
Last := Str'First + Filename_Len - 1;
else