On Wed, 6 Oct 2010, Sven Barth wrote:
Am 05.10.2010 17:41, schrieb Jonas Maebe:
On 05 Oct 2010, at 17:38, Michael Van Canneyt wrote:
On Tue, 5 Oct 2010, Leonardo M. Ramé wrote:
Hi, if I run this program from command line in Linux, I allways get the
same result, "/tmp/TMP00000.tmp". Shouldn't it return a different file
name each time it's executed?.
How can I get different file names?
By actually creating the file. GetTempFileName does not create a file, but
does check whether the filename exists.
What is the use of that? Between the check and creating the file, some
other process may already have created it.
This is always true on Unix, the only way to make sure is to have the kernel
create the temporary name and file for you. Unix - to my knowledge - does not
have a way to create and lock a file in one atomic operation; There are
always 2 operations involved, and so anything can happen between the 2
calls.
That might be the reason why Windows is creating the file for you if you call
GetTempFileName... so GetTempFileName in FPC does not expose the same
behavior on non-Windows and Windows.
I'm open for some more sophisticated algorithm which does some more checking.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal