Markus Neteler wrote: > could anyone please implement G_mktemp() following the suggestions in > the ticket (there is a link to a gfortran patch included which might > be just "perfect":
I've added lib/gis/mkstemp.c, which needs testing and feedback. G_mktemp() just generates the filename; as such it is prone to race conditions (some other process may create that file after G_mktemp() returns). G_mkstemp() opens the file and returns a descriptor. G_mkstemp_fp() opens the file and returns a FILE*. The last two take the arguments "flags" and "mode". "flags" should be O_WRONLY or O_RDWR, plus any other desired flags (e.g. O_APPEND). "mode" is the file mode (0666 would be typical). None of the functions use the PID, although the caller can do so. In theory, up to 26^5 (= ~12 million) filenames will be attempted until it finds one which doesn't exist. In retrospect, it should probably use the last 5 Xs rather than the first, as you may not be able to control the names of the leading directories. Or the first 5 Xs after the last / or \. Or something. But I'll wait to see what other comments are made before changing anything. -- Glynn Clements <gl...@gclements.plus.com> _______________________________________________ grass-dev mailing list grass-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-dev