From patchwork Thu Apr 11 12:46:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 235729 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 1A5D22C00C8 for ; Thu, 11 Apr 2013 22:46:52 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=DWv686gJ0K9YqaWnYt8M4hwZRiiljKGDa48C5GEQv2Oqq97p/Y c6dS6w33KbOdKQQ9fBsaoijxxajU9/fBre0kqGTnuZ/DC58o4GGXg+vkItH1WR4j ITKnWLT0rSjAmBQbkneKBpPE3+I0wLFfPFmuUjB6yQdZ8V9/rNxoJ8pJY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=lPFHaV4MSL9HfKgB/zw44vc6WpI=; b=ydsBdewLZ5CLZkrGMVAe oikLx3jKxTH66plXxcRvHv7gC/1fJt7ysioMg7KQb61ug+vTiymwTLctjsXAANrm 3rHz+4Ph3M6VVq9ecbNpH49x8NZxdgSG7vWG/VQY4z4HQudZKNhBpW61nolfEPf/ Zve/HNIkxZBilu/Sl/Uh8Gc= Received: (qmail 21557 invoked by alias); 11 Apr 2013 12:46:37 -0000 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 Received: (qmail 21531 invoked by uid 89); 11 Apr 2013 12:46:37 -0000 X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO, TW_PR autolearn=ham version=3.3.1 Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 11 Apr 2013 12:46:36 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 14BAB2E817; Thu, 11 Apr 2013 08:46:35 -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 IYenX0bF3QXJ; Thu, 11 Apr 2013 08:46:35 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id E252E2E123; Thu, 11 Apr 2013 08:46:34 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id E19193FF09; Thu, 11 Apr 2013 08:46:34 -0400 (EDT) Date: Thu, 11 Apr 2013 08:46:34 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Celier Subject: [Ada] gnatname and temporary files Message-ID: <20130411124634.GA2669@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Found: No Instead of creating then deleting multiple times the same temporary file, gnatname now creates then deletes temporary files with distinct names. In addition, if environment variable TMPDIR exists, the temporary files are created in this directory. No change in gnatname behavior, so no test. Tested on x86_64-pc-linux-gnu, committed on trunk 2013-04-11 Vincent Celier * prj-makr.adb (Process_Directory): Create a new temporary file for each invocation of the compiler, in directory pointed by environment variable TMPDIR if it exists. Index: prj-makr.adb =================================================================== --- prj-makr.adb (revision 197752) +++ prj-makr.adb (working copy) @@ -38,6 +38,7 @@ with Sdefault; with Snames; use Snames; with Table; use Table; +with Tempdir; with Ada.Characters.Handling; use Ada.Characters.Handling; with GNAT.Directory_Operations; use GNAT.Directory_Operations; @@ -1235,6 +1236,7 @@ Success : Boolean; Saved_Output : File_Descriptor; Saved_Error : File_Descriptor; + Tmp_File : Path_Name_Type; begin -- If we don't have the path of the compiler yet, @@ -1256,19 +1258,17 @@ end if; end if; - -- If we don't have yet the file name of the - -- temporary file, get it now. + -- Create the temporary file - if Temp_File_Name = null then - Create_Temp_File (FD, Temp_File_Name); + Tempdir.Create_Temp_File (FD, Tmp_File); - if FD = Invalid_FD then - Prj.Com.Fail - ("could not create temporary file"); - end if; + if FD = Invalid_FD then + Prj.Com.Fail + ("could not create temporary file"); - Close (FD); - Delete_File (Temp_File_Name.all, Success); + else + Temp_File_Name := + new String'(Get_Name_String (Tmp_File)); end if; Args (Args'Last) := new String' @@ -1276,16 +1276,6 @@ Directory_Separator & Str (1 .. Last)); - -- Create the temporary file - - FD := Create_Output_Text_File - (Name => Temp_File_Name.all); - - if FD = Invalid_FD then - Prj.Com.Fail - ("could not create temporary file"); - end if; - -- Save the standard output and error Saved_Output := Dup (Standout); @@ -1331,7 +1321,8 @@ if not Is_Valid (File) then Prj.Com.Fail - ("could not read temporary file"); + ("could not read temporary file " & + Temp_File_Name.all); end if; Save_Last_Source_Index := Sources.Last;