Commit d3b1401d by Thomas Quinot Committed by Arnaud Charlet

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
parent d045b076
...@@ -38,7 +38,6 @@ with Interfaces.C_Streams; use Interfaces.C_Streams; ...@@ -38,7 +38,6 @@ with Interfaces.C_Streams; use Interfaces.C_Streams;
with System.CRTL; with System.CRTL;
with System.Case_Util; use System.Case_Util; with System.Case_Util; use System.Case_Util;
with System.OS_Constants;
with System.OS_Lib; with System.OS_Lib;
with System.Soft_Links; with System.Soft_Links;
...@@ -994,11 +993,25 @@ package body System.File_IO is ...@@ -994,11 +993,25 @@ package body System.File_IO is
-- Should we raise Device_Error for ENOSPC??? -- Should we raise Device_Error for ENOSPC???
if System.OS_Lib.Errno = System.OS_Constants.ENOENT then declare
raise Name_Error; subtype Cint is Interfaces.C.int;
else
raise Use_Error; function Is_File_Not_Found_Error
end if; (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; end if;
end if; end if;
......
...@@ -35,9 +35,14 @@ ...@@ -35,9 +35,14 @@
#ifdef __vxworks #ifdef __vxworks
#include "ioLib.h" #include "ioLib.h"
#include "dosFsLib.h"
#ifndef __RTP__
# include "nfsLib.h"
#endif
#include "selectLib.h" #include "selectLib.h"
#include "vxWorks.h" #include "vxWorks.h"
#endif #endif
#ifdef IN_RTS #ifdef IN_RTS
#define POSIX #define POSIX
#include "tconfig.h" #include "tconfig.h"
...@@ -53,6 +58,7 @@ ...@@ -53,6 +58,7 @@
#endif #endif
#include <time.h> #include <time.h>
#include <errno.h>
#if defined (sun) && defined (__SVR4) && !defined (__vxworks) #if defined (sun) && defined (__SVR4) && !defined (__vxworks)
/* The declaration is present in <time.h> but conditionalized /* The declaration is present in <time.h> but conditionalized
...@@ -893,3 +899,23 @@ __gnat_get_task_options (void) ...@@ -893,3 +899,23 @@ __gnat_get_task_options (void)
} }
#endif #endif
int
__gnat_is_file_not_found_error (int errno_val) {
switch (errno_val) {
case ENOENT:
#ifdef __vxworks
/* In the case of VxWorks, we also have to take into account various
* filesystem-specific variants of this error.
*/
case S_dosFsLib_FILE_NOT_FOUND:
#ifndef __RTP__
case S_nfsLib_NFSERR_NOENT:
#endif
#endif
return 1;
default:
return 0;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment