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,7300df8db68b4232 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!n2g2000prj.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: more Ada.Directories questions Date: Fri, 1 Apr 2011 08:27:46 -0700 (PDT) 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 1301671666 2513 127.0.0.1 (1 Apr 2011 15:27:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 1 Apr 2011 15:27:46 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: n2g2000prj.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:19640 Date: 2011-04-01T08:27:46-07:00 List-Id: On Mar 31, 10:49=A0pm, tmo...@acm.org wrote: > Does Ada.Directories.Create_Directory("X"); raise Use_Error if directory = X > already exists? =A0It seems it should if the system does not support > creation of something that already exists. =A0(On Windows at least, mkdir= x > fails if x already exists.) Ditto if file "X" exists and the system won't > allow a file and a directory of the same name. =A0Does "Create" mean "cha= nge > the state of the file system" or does it mean "arrange that the file > system has a certain state"? =A0Create_Directory apparently means the > former. > > Apparently the latter meaning applies to Create_Path, since > according to the Rationale, Ada.Directories.Create_Path("X"); > does not raise Use_Error, but is a NOP, if directory X exists. I wonder if this was the intent. If you say Create_Path("/a/b/c"), then clearly the intent is to create /a and /a/b if they don't exist, but use the existing ones if they do. I'm not certain that that was supposed to apply to the final directory name, /a/b/c. > So the only reason to use Create_Directory rather than Create_Path is > to detect the case where a file or directory of that name already > exists, correct? Incorrect, I think. Create_Path will create other directories along the path if they don't exist, and that may not be what you want. Suppose Arg is a command-line argument and I want to say something like Create_Directory (Arg & "/Work_Directory"); [actually, I'd use other routines to create the path name instead of "&", but that's not relevant to my point]. If Arg includes a directory component that doesn't exist because it's misspelled, I'd want Create_Directory to fail---not to go ahead and create a new misspelled path. > If "???" is an illegal name for a directory, it seems that > Create_Path("a/b/???/c"); will raise Name_Error without creating "a/b". > Correct? I don't think the RM is clear on this. In fact, it may be unfeasible to implement Create_Path in a way that doesn't attempt to create earlier directories before finding out that a later one has a bad name, if the implementation depends on the OS to tell it whether a name is bad or not. In fact, this raises another question: suppose a/ b cannot be created for some reason (no permission), then does the above Create_Path call raise Use_Error or Name_Error? My guess is "not specified by the language". -- Adam