* [Ada] Delete symbolic link silently.
@ 2012-06-12 10:31 Arnaud Charlet
0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2012-06-12 10:31 UTC (permalink / raw)
To: gcc-patches; +Cc: Pascal Obry
[-- Attachment #1: Type: text/plain, Size: 705 bytes --]
The following test must run without raising an exception on
systems supporting symbolic links:
with Ada.Directories; use Ada.Directories;
with Ada.Text_IO; use Ada.Text_IO;
procedure Delln is
F1 : constant String := "libname.so";
F2 : constant String := "libname.so.1";
File : File_Type;
begin
Delete_File (F1);
Delete_File (F2);
end Delln;
$ touch libname.so
$ ln -s libname.so libname.so.1
$ gnatmake -a delln
Tested on x86_64-pc-linux-gnu, committed on trunk
2012-06-12 Pascal Obry <obry@adacore.com>
* a-direct.adb (Delete_File): Delete symbolic links silently
instead of raising the Name_Error exception when the symbolic
link is pointing to a non existent file.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1479 bytes --]
Index: a-direct.adb
===================================================================
--- a-direct.adb (revision 188428)
+++ a-direct.adb (working copy)
@@ -31,20 +31,20 @@
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
+with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Directories.Validity; use Ada.Directories.Validity;
+with Ada.Strings.Fixed;
with Ada.Strings.Maps; use Ada.Strings.Maps;
-with Ada.Strings.Fixed;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
-with Ada.Characters.Handling; use Ada.Characters.Handling;
+with System; use System;
with System.CRTL; use System.CRTL;
+with System.File_IO; use System.File_IO;
with System.OS_Constants; use System.OS_Constants;
with System.OS_Lib; use System.OS_Lib;
with System.Regexp; use System.Regexp;
-with System.File_IO; use System.File_IO;
-with System; use System;
package body Ada.Directories is
@@ -561,7 +561,9 @@
if not Is_Valid_Path_Name (Name) then
raise Name_Error with "invalid path name """ & Name & '"';
- elsif not Is_Regular_File (Name) then
+ elsif not Is_Regular_File (Name)
+ and then not Is_Symbolic_Link (Name)
+ then
raise Name_Error with "file """ & Name & """ does not exist";
else
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-06-12 10:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-12 10:31 [Ada] Delete symbolic link silently Arnaud Charlet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).