aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/s-fileio.adb
diff options
context:
space:
mode:
authorThomas Quinot <quinot@adacore.com>2008-08-20 14:35:11 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2008-08-20 14:35:11 +0200
commitd3b1401d07ff4874964a8b534dfd8cd94dc978ae (patch)
treed22b7988ca725589e64a5a1327e1a9cd93db79a5 /gcc/ada/s-fileio.adb
parentd045b07645aa858dfd6be481fcc17921d924b7b0 (diff)
downloadgcc-d3b1401d07ff4874964a8b534dfd8cd94dc978ae.zip
gcc-d3b1401d07ff4874964a8b534dfd8cd94dc978ae.tar.gz
gcc-d3b1401d07ff4874964a8b534dfd8cd94dc978ae.tar.bz2
2008-08-20 Thomas Quinot <quinot@adacore.com>
* s-fileio.adb (Open) Use C helper function to determine whether a given errno value corresponds to a "file not found" error. * sysdep.c (__gnat_is_file_not_found_error): New C helper function. From-SVN: r139283
Diffstat (limited to 'gcc/ada/s-fileio.adb')
-rw-r--r--gcc/ada/s-fileio.adb25
1 files changed, 19 insertions, 6 deletions
diff --git a/gcc/ada/s-fileio.adb b/gcc/ada/s-fileio.adb
index 7c20fb1..1109b22 100644
--- a/gcc/ada/s-fileio.adb
+++ b/gcc/ada/s-fileio.adb
@@ -38,7 +38,6 @@ with Interfaces.C_Streams; use Interfaces.C_Streams;
with System.CRTL;
with System.Case_Util; use System.Case_Util;
-with System.OS_Constants;
with System.OS_Lib;
with System.Soft_Links;
@@ -994,11 +993,25 @@ package body System.File_IO is
-- Should we raise Device_Error for ENOSPC???
- if System.OS_Lib.Errno = System.OS_Constants.ENOENT then
- raise Name_Error;
- else
- raise Use_Error;
- end if;
+ declare
+ subtype Cint is Interfaces.C.int;
+
+ function Is_File_Not_Found_Error
+ (Errno_Value : Cint) return Cint;
+ -- Non-zero when the given errno value indicates a non-
+ -- existing file.
+
+ pragma Import (C, Is_File_Not_Found_Error,
+ "__gnat_is_file_not_found_error");
+ begin
+ if Is_File_Not_Found_Error (Cint (System.OS_Lib.Errno))
+ /= 0
+ then
+ raise Name_Error;
+ else
+ raise Use_Error;
+ end if;
+ end;
end if;
end if;
end if;