() Andy Wingo <[email protected]>
() Mon, 08 Feb 2010 12:11:17 +0100

   I think this sounds like a good idea. I have a few concerns, though if
   none of them can be nicely addressed I'd still be happy adding tmpfile.

I'm happy to see Ken Raeburn answer these concerns.  Personally, i find it
very nice to have an anonymous seekable chunk of filesystem to play with.

BTW (veering off-topic, but you started it!)... i dislike `mkstemp!'.
Its safe use requires `string-copy'.  Why not have all that handled
automatically, including the "XXXXXX" suffixing?  That's what i do
in Guile 1.4.x `mkstemp' (note, no "!").

thi

__________________________________________________
SCM_DEFINE
(scm_mkstemp, "mkstemp", 1, 0, 0,
 (SCM base),
 doc: /***********
Return a new port open on a temporary file named using string @var{base}.
The actual assigned filename, available via procedure @code{port-filename},
is @var{base} appended with six random characters.  For example:

@lisp
(define p (mkstemp "/tmp/foo-"))
(port-filename p)
@result{} "/tmp/foo-hoQtxh"
@end lisp  */)
{
#define FUNC_NAME s_scm_mkstemp
  char *s;
  size_t len;
  int fd;

  SCM_VALIDATE_STRING (1, base);
  len = SCM_ROLENGTH (base) + 6 + 1;
  s = alloca (len);
  snprintf (s, len, "%sXXXXXX", SCM_ROCHARS (base));

  if (PROB (fd = mkstemp (s)))
    SCM_SYSERROR;

  return scm_fdes_to_port (fd, "w+", STRFROM (s, len - 1));
#undef FUNC_NAME
}



Reply via email to