From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,17f674692867d416 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!a6g2000yqm.googlegroups.com!not-for-mail From: vlc Newsgroups: comp.lang.ada Subject: Re: Atomic file creation Date: Mon, 4 Jan 2010 06:24:26 -0800 (PST) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 87.221.73.92 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1262615066 9169 127.0.0.1 (4 Jan 2010 14:24:26 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 4 Jan 2010 14:24:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a6g2000yqm.googlegroups.com; posting-host=87.221.73.92; posting-account=ROuOHgoAAABopjDuvPBd02HgYVR-VCZk User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.6) Gecko/20091215 Ubuntu/9.10 (karmic) Firefox/3.5.6,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:8589 Date: 2010-01-04T06:24:26-08:00 List-Id: I also tried something like this: 1 Ada.Text_IO.Create (Handle, Out_File); 2 declare 3 Temp_File : String := Ada.Text_IO.Name (Handle); 4 begin 5 Ada.Text_IO.Close (Handle); 6 Ada.Text_IO.Rename (Temp_File, "file"); 7 Ada.Text_IO.Put_Line ("Success"); 8 exception 9 when Ada.IO_Exceptions.Use_Error => 10 Ada.Text_IO.Put_Line ("Failure"); 11 when others => 12 raise; 13 end; But Ada.Text_IO.Rename always raises Ada.IO_Exceptions.Use_Error, even if the file does not exist. But if I replace line 1 with 1 Ada.Text_IO.Create (Handle, Out_File, "my_temp_file"); it works. It seems that Ada.Text_IO.Rename cannot rename temporary files for whatever reason. Using Ada.Directories.Copy_File instead of Ada.Text_IO.Rename does not help as Ada.Directories.Copy_File overwrites files without raising an exception. Bad luck ...