comp.lang.ada
 help / color / mirror / Atom feed
From: emery@ARIES.MITRE.ORG (David Emery)
Subject: re: Ada/UNIX(tm) and the NAME function
Date: 28 Dec 88 16:38:54 GMT	[thread overview]
Message-ID: <8812281638.AA00722@aries> (raw)

This is not a significant problem on Unix.  First, you should get an
absolute pathname to the file.  This should be interpreted according
to Unix semantics.  My understanding of this is that, for a relative
pathname, the effect is as if current value of the process' working
directory is prepended to the relative pathname, converting it to an
absolute pathname.  This is then used to get the file.  (note that
there are plenty of optimizations here, particularly those that
"cache" the path traversal to get to the working directory).  There is
no requirement for Ada to determine the "best" path to a file, only
the absolute pathname used to open the file.

So, the Ada implementation of Text_IO.OPEN (or whatever) does the same
thing.  If the pathname isn't absolute, call Unix.getcwd, append the
pathname to this string, and associate it with the FILE_TYPE object.
(More specifically, store it inside the private FILE_TYPE object.)
Note that there is NO requirement to walk the directory chain.  If
Unix can open the file, then this is a good filename; if Unix cannot
open the file, then of course there is no reasonable name associated
with the FILE_TYPE object.  (So call Unix.open before 'calculating'
the file name.)

TEXT_IO.NAME then looks like 
	return FILE.FILE_NAME;
and NAME_ERROR is raised if file_type.file_name has no 'legal' value.

Of course, you have the potential problem of losing access to the file
during the execution of the process.  (For instance, someone clobbers
/usr).  This will always be true with Unix, so Ada shouldn't attempt
to fix Unix.

Naturally, Robert Firth's comment about exceptions is right on the
money.  

One of the things on our "agenda" for the Ada Binding to POSIX is to
provide a reasonable POSIX "binding" interpretation of Ada's TEXT_IO
in a POSIX environment (things like the meaning of FORM string, etc.)
We will discuss this issue at our next meeting but I would be very
surprised we came up with any other interpretation.  We will have to
think a bit about what is returned by TEXT_IO.NAME(TEXT_IO.STANDARD_INPUT).  
Furthermore, I suspect that we will in general try to better define
and possibly restrict the exceptions that a conforming POSIX
implementation can raise for TEXT_IO operations (e.g. restrict
TEXT_IO.NAME to raising STATUS_ERROR, and then only when the given
file hasn't been opened.)  

			dave emery
			(Technical Co-Editor, IEEE POSIX Ada Binding)
			mitre
			emery@mitre.org (new style)
			emery@mitre-bedford.arpa (old style)
			
"Advertisment": for more information on the POSIX Ada binding, contact
me.  To get on the Email list discussing the binding, send mail to
	posix-ada-request@grebyn.com

             reply	other threads:[~1988-12-28 16:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1988-12-28 16:38 David Emery [this message]
1988-12-30 17:35 ` Ada/UNIX(tm) and the NAME function Barry Margolin
1988-12-30 22:08   ` Dik T. Winter
1989-01-03 20:03 ` John Stafford
  -- strict thread matches above, loose matches on Subject: below --
1989-01-01  0:01 Erland Sommarskog
1988-12-20 19:40 John Stafford
1988-12-21 19:43 ` Robert Firth
1989-01-03 15:19   ` Stephe Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox