Commit 468ee337 by Pascal Obry Committed by Arnaud Charlet

adaint.h, adaint.c (__gnat_rmdir): New routine.

2009-04-16  Pascal Obry  <obry@adacore.com>

	* adaint.h, adaint.c (__gnat_rmdir): New routine.
	Simple wrapper routines used to convert to proper encoding on
	Windows.

	* s-crtl.ads: Use __gnat_rmdir instead of direct call to the C library.

	* g-dirope.adb (Remove_Dir): Fix a bug, the root directory was removed
	twice.

From-SVN: r146176
parent bca17d51
2009-04-16 Pascal Obry <obry@adacore.com>
* adaint.h, adaint.c (__gnat_rmdir): New routine.
Simple wrapper routines used to convert to proper encoding on
Windows.
* s-crtl.ads: Use __gnat_rmdir instead of direct call to the C library.
* g-dirope.adb (Remove_Dir): Fix a bug, the root directory was removed
twice.
2009-04-16 Pascal Obry <obry@adacore.com>
* s-crtl.ads, s-os_lib.adb: Minor code clean-up.
2009-04-16 Thomas Quinot <quinot@adacore.com>
......@@ -70,7 +70,7 @@ package body Ada.Directories is
type Search_Data is record
Is_Valid : Boolean := False;
Name : Ada.Strings.Unbounded.Unbounded_String;
Name : Unbounded_String;
Pattern : Regexp;
Filter : Filter_Type;
Dir : Dir_Type_Value := No_Dir;
......@@ -481,9 +481,7 @@ package body Ada.Directories is
C_Dir_Name : constant String := Directory & ASCII.NUL;
begin
rmdir (C_Dir_Name);
if System.OS_Lib.Is_Directory (Directory) then
if rmdir (C_Dir_Name) /= 0 then
raise Use_Error with
"deletion of directory """ & Directory & """ failed";
end if;
......@@ -565,9 +563,7 @@ package body Ada.Directories is
C_Dir_Name : constant String := Directory & ASCII.NUL;
begin
rmdir (C_Dir_Name);
if System.OS_Lib.Is_Directory (Directory) then
if rmdir (C_Dir_Name) /= 0 then
raise Use_Error with
"directory tree rooted at """ &
Directory & """ could not be deleted";
......
......@@ -725,6 +725,23 @@ __gnat_chdir (char *path)
#endif
}
/* Removing a directory. */
int
__gnat_rmdir (char *path)
{
#if defined (__MINGW32__) && ! defined (__vxworks) && ! defined (CROSS_COMPILE)
{
TCHAR wpath[GNAT_MAX_PATH_LEN];
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
return _trmdir (wpath);
}
#else
return rmdir (path);
#endif
}
FILE *
__gnat_fopen (char *path, char *mode, int encoding ATTRIBUTE_UNUSED)
{
......
......@@ -73,6 +73,7 @@ extern int __gnat_stat (char *,
extern int __gnat_unlink (char *);
extern int __gnat_rename (char *, char *);
extern int __gnat_chdir (char *);
extern int __gnat_rmdir (char *);
extern FILE *__gnat_fopen (char *, char *, int);
extern FILE *__gnat_freopen (char *, char *, FILE *,
......
......@@ -739,9 +739,7 @@ package body GNAT.Directory_Operations is
-- Remove the directory only if it is empty
if not Recursive then
rmdir (C_Dir_Name);
if GNAT.OS_Lib.Is_Directory (Dir_Name) then
if rmdir (C_Dir_Name) /= 0 then
raise Directory_Error;
end if;
......@@ -764,7 +762,6 @@ package body GNAT.Directory_Operations is
Str (1 .. Last) /= ".."
then
Remove_Dir (Str (1 .. Last), True);
Remove_Dir (Str (1 .. Last));
end if;
else
......
......@@ -164,8 +164,8 @@ package System.CRTL is
procedure rewind (stream : FILEs);
pragma Import (C, rewind, "rewind");
procedure rmdir (dir_name : String);
pragma Import (C, rmdir, "rmdir");
function rmdir (dir_name : String) return int;
pragma Import (C, rmdir, "__gnat_rmdir");
function chdir (dir_name : String) return int;
pragma Import (C, chdir, "__gnat_chdir");
......
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