From patchwork Tue Jun 12 10:16:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 164371 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 1423BB6FB9 for ; Tue, 12 Jun 2012 20:16:39 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1340101000; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=8CvI3sUNRLh8ncgR3TSV wcbX7N0=; b=mE/S6GLmd4JxiOmrbHsHGLuaU/DTH8IMWFfJjvhCvC6bj2sdw4z7 Vg8d180/Jq9kf6/D832QirP40Mr0efBW79Ig29V+NkrXmdtLovIovXyemLtAyIKk YIcjFqSjEswR0QFLjKniktgR7ACJdOHbWY5msU9J11Zrqr91UdGuikI= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=EWpSE672cE5KTC/fnHWILlKDA5xHb/BioQLE7MPHCfEMyFHun9w8SivrCjuYIN snNlsdQGLTsO1ZpFEACsSN1QT8aoSfU+1uvVVgXXo6W7rzqqagq2siC+3RUnon5w rck+ONWk48NjNXQOfe61ZRAMAb2XgKss1RQxGbVqdZkZ0=; Received: (qmail 25293 invoked by alias); 12 Jun 2012 10:16:33 -0000 Received: (qmail 25277 invoked by uid 22791); 12 Jun 2012 10:16:32 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Jun 2012 10:16:20 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 766C21C6F66; Tue, 12 Jun 2012 06:16:19 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id iB74bdFFGvmH; Tue, 12 Jun 2012 06:16:19 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id C49121C6F13; Tue, 12 Jun 2012 06:16:18 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id C028492BF6; Tue, 12 Jun 2012 06:16:18 -0400 (EDT) Date: Tue, 12 Jun 2012 06:16:18 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Pascal Obry Subject: [Ada] Delete symbolic link silently. Message-ID: <20120612101617.GA20119@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 * 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. 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