comp.lang.ada
 help / color / mirror / Atom feed
From: Gautier <gautier.demontmollin@maths.unine.ch>
Subject: Re: Create-Delete tmp Files
Date: 2000/03/20
Date: 2000-03-20T00:00:00+00:00	[thread overview]
Message-ID: <38D63810.6E679322@maths.unine.ch> (raw)
In-Reply-To: slrn8dc5mp.2d7.randhol@kiuk0156.chembio.ntnu.no

> >Maybe you need a more permanent file. A way is to try creating
> >files like "tempfile.100". If there must be several, you check
> >for existence of "tempfile.100", "tempfile.101", etc. until
> >there is a name free.

Preben Randhol wrote:

> How would you do this codewise?

You make a loop with i in 100 .. 999 and check existence of
"tempfile." & integer'image(i). If the file doesn't exist, you
decide it is the good one: you return the name. Of course one has
to be careful if there are parallel tasks doing the same, to lock
the free name as soon as possible maybe by creating an bogus file with
that name or a more solid method with an array of boolean of the range
(say Name_locked:= (others=> false)).
If the loop exists normally, you raise an exception such as
no_name_available_for_temp_file...

This is coded +/- so in the AD trace-back interface for GNAT
( source ad.adb in zip file http://members.xoom.com/gdemont/logiciel/ad.zip
  or in AdaGIDE,
  web page http://members.xoom.com/gdemont/ad.htm )

_____________________________________________
Gautier  --  http://members.xoom.com/gdemont/




  reply	other threads:[~2000-03-20  0:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-17  0:00 Create-Delete tmp Files Achim Gerhard
2000-03-17  0:00 ` John J Cupak Jr
2000-03-18  0:00   ` Robert Dewar
2000-03-20  0:00     ` Achim Gerhard
2000-03-20  0:00       ` Robert A Duff
2000-03-20  0:00         ` Achim Gerhard
2000-03-20  0:00           ` Robert A Duff
2000-03-20  0:00       ` tmoran
2000-03-21  0:00         ` Achim Gerhard
2000-03-21  0:00           ` Roger Barnett
2000-03-23  0:00             ` Achim Gerhard
2000-03-23  0:00               ` Robert Dewar
2000-03-24  0:00                 ` Achim Gerhard
2000-03-24  0:00                   ` Robert Dewar
2000-03-23  0:00               ` tmoran
2000-03-21  0:00           ` Robert Dewar
2000-03-20  0:00       ` Gautier
2000-03-20  0:00         ` Preben Randhol
2000-03-20  0:00           ` Gautier [this message]
2000-03-20  0:00             ` Preben Randhol
2000-03-17  0:00 ` Robert Dewar
replies disabled

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