]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
adaint.h, adaint.c (__gnat_rmdir): New routine.
authorPascal Obry <obry@adacore.com>
Thu, 16 Apr 2009 12:24:19 +0000 (12:24 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 16 Apr 2009 12:24:19 +0000 (14:24 +0200)
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

gcc/ada/ChangeLog
gcc/ada/a-direct.adb
gcc/ada/adaint.c
gcc/ada/adaint.h
gcc/ada/g-dirope.adb
gcc/ada/s-crtl.ads

index 12b55c681b6b5a4ca20f1a2146345e6459c05f56..aba44e835d0324f158043afb30c7b1d5d630cbac 100644 (file)
@@ -1,3 +1,14 @@
+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.
index 07f5836ff03880818136d45348ee8b6543c1675f..db9ef9f7c517cebc0683b9b2929136229095611a 100644 (file)
@@ -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";
index a777467e27d96387df94593ded55c9a5c0028a91..43ec6543ea539691ea17dc8f1f756733e1f5b063 100644 (file)
@@ -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)
 {
index 134cca303027147bffae27b307ac03dff47b80ff..5ed4d76a91b6b02a5a6b16b0e2cbef3f955fce96 100644 (file)
@@ -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 *,
index 33086ed17660d32a8c7c3f10a953650cd291bb83..c7670ef558b7430555646407af8b9cc8379c44ed 100644 (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
index 4c76ccfd611c2316338676c706550e340e308f5a..aa4a8b57086699f2511981e25e645289cb78f52b 100644 (file)
@@ -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");