comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey D. Cherry" <jdcherry@utech.net>
Subject: Re: Temporary files in Ada95.
Date: 1999/03/31
Date: 1999-03-31T00:00:00+00:00	[thread overview]
Message-ID: <37026630.D6B9207C@utech.net> (raw)
In-Reply-To: VOpM2.2090$dF4.8591492@WReNphoon1

Jeffrey,

(Great name BTW.)

I don't think you want to ask "Is there a way to make ada not write
temporary files to the root directory?" since it's not really a language
issue.  I view it as an implementation issue.  I would have thought that
GNAT would create the temporary file in a directory where the user has
write access.  My test showed I was mistaken and your results are
apparently the same.  From this limited experiment I conclude that the
default behavior for creating temporary files, as defined in the Ada
LRM, must be used with caution, i.e., trap exceptions for the case where
write access is denied by the operating system. In terms of GNAT, I'm
guessing their implementation decision was due to either portability
issues or simplification based on standard C I/O functions.  To their
credit, I haven't found any violation of the rules defined in the Ada
LRM.

For your particular development effort on Windows NT, may I suggest you
look in the Win32 library of services.  Specifically, look in the
package Win32.Winbase and you will find two functions that are designed
for creating temporary files.  These functions are named GetTempPath and
GetTempFileName.  The GetTempPath function provides the path defined by
the environment variable TMP, or TEMP is TMP does not exist, or the
current directory if neither TMP or TEMP exist.  This path can then be
passed to GetTempFileName which will provide you with a unique file name
within the given directory.  Refer to the documentation for
GetTempFileName for additional options.  This should work for all users
under NT unless the Administrator has denied them access to the system
TEMP directory; an unusual condition in which case your program may have
to abort or ask the user to provide a location where a temporary file
may be created.  Please note that the downside of this method is that
the file is NOT deleted once the program terminates.  You must remember
to delete it yourself.

Hope this helps!

Regards,

Jeffrey D. Cherry




  reply	other threads:[~1999-03-31  0:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-25  0:00 Temporary files in Ada95 jboulais
1999-03-26  0:00 ` Matthew Heaney
1999-03-26  0:00 ` Boulais, Jeffrey M
1999-03-26  0:00   ` Matthew Heaney
1999-03-26  0:00 ` robert_dewar
1999-03-26  0:00 ` Boulais, Jeffrey M
1999-03-26  0:00   ` Boulais, Jeffrey M
1999-04-02  0:00     ` Jerry van Dijk
1999-03-26  0:00   ` Jeffrey D. Cherry
1999-03-26  0:00     ` Larry Kilgallen
1999-03-29  0:00       ` Jeffrey D. Cherry
1999-03-31  0:00       ` Boulais, Jeffrey M
1999-03-31  0:00         ` Jeffrey D. Cherry [this message]
1999-03-31  0:00           ` Matthew Heaney
1999-03-31  0:00             ` Jeffrey D. Cherry
1999-04-01  0:00               ` John J Cupak Jr
1999-03-26  0:00   ` Matthew Heaney
replies disabled

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