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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1295f20108acc30c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!o21g2000prn.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Ada.Directories.Copy_File behavior Date: Mon, 21 Feb 2011 10:05:40 -0800 (PST) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1298311541 28039 127.0.0.1 (21 Feb 2011 18:05:41 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 21 Feb 2011 18:05:41 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: o21g2000prn.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:18492 Date: 2011-02-21T10:05:40-08:00 List-Id: On Feb 19, 3:01=A0pm, "Vinzent Hoefler" <0439279208b62c95f1880bf0f8776...@t-domaingrabbing.de> wrote: > =A0 wrote: > > If the Target_Name file already exists, does Copy_File raise an excepti= on, > > or does it replace the old file? =A0I can't seem to find where the beha= vior > > is specified in the ARM. > > |The exception Use_Error is propagated if the external environment does n= ot > |support creating the file with the name given by Target_Name > > So, the actual behaviour depends on the underlying OS, I'd say. Note that the phrase you quote says "does not support creating". Which is basically the same as the language used in the description of Create operations (see A.8.2(5)). The language does *not* say "does not support copying to" or anything of that sort. So I think Copy_File is supposed to work any time Create will work, including when the file already exists (assuming the permissions are such that the file can be overwritten). And, barring permission/ownership issues, Create normally does not raise an exception if you give it the name of an existing file. In other words, the answer to the OP's question is that it replaces the existing file, if it can. There are still some implementation dependencies with regard to existing files that are marked as read- only or "do-not-delete" or owned by some other user, which I think apply to both Create and Copy_File. If the OS has a "copy file" operation that does not allow an existing file as the target, then Ada.Directories has to work around that, perhaps by checking for an existing file first and deleting it. That's how I interpret the RM, but (disclaimer) I'm not an ARG member and am not really an authority. -- Adam