
tis 2003-05-27 klockan 11.25 skrev Peter Simons:
Martin Norbäck writes:
[...] perhaps you want to return (String, Handle) so that you know the file name (in case you want to do something else than just reading/writing from it).
IMHO there should be a way to obtain _only_ the generated file name, without opening a file at all, because I may want to use this name to create a _directory_ rather than a file.
There's char *mktemp(char *template) but it's not Safe: BUGS Never use mktemp(). Some implementations follow BSD 4.3 and replace XXXXXX by the current process id and a single letter, so that at most 26 different names can be returned. Since on the one hand the names are easy to guess, and on the other hand there is a race between testing whether the name exists and opening the file, every use of mktemp() is a security risk. The race is avoided by mkstemp(3). There is, however, also char *mkdtemp(char *template) (available in openbsd 2.2+ and glibc 2.1.91, can't speak for others) which is also easy to wrap. /Martin -- Martin Sjögren sjogren@debian.org -- marvin@dum.chalmers.se GPG key: http://www.mdstud.chalmers.se/~md9ms/gpg.html let hello = "hello" : hello in putStr (unlines hello)