+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.
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;
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;
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";
#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)
{
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 *,
-- 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;
Str (1 .. Last) /= ".."
then
Remove_Dir (Str (1 .. Last), True);
- Remove_Dir (Str (1 .. Last));
end if;
else
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");