From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.lisp.guile.user Subject: Re: request tmpfile(3) wrapping in Guile 1.9 libguile Date: Tue, 09 Feb 2010 10:07:14 +0100 Message-ID: <87wrymojzx.fsf@ambire.localdomain> References: <877hqoubkv.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1265722117 8329 80.91.229.12 (9 Feb 2010 13:28:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Feb 2010 13:28:37 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Feb 09 14:28:32 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Neq8m-0002ex-5j for guile-user@m.gmane.org; Tue, 09 Feb 2010 14:28:32 +0100 Original-Received: from localhost ([127.0.0.1]:43496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Neq8l-0004WN-Aq for guile-user@m.gmane.org; Tue, 09 Feb 2010 08:28:31 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Neq8P-0004VT-Ig for guile-user@gnu.org; Tue, 09 Feb 2010 08:28:09 -0500 Original-Received: from [199.232.76.173] (port=38208 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Neq8O-0004V6-K9 for guile-user@gnu.org; Tue, 09 Feb 2010 08:28:08 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Neq8L-0000P9-0e for guile-user@gnu.org; Tue, 09 Feb 2010 08:28:08 -0500 Original-Received: from host121-36-dynamic.24-79-r.retail.telecomitalia.it ([79.24.36.121]:38349 helo=ambire.localdomain) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Neq8K-0000Oz-Ji for guile-user@gnu.org; Tue, 09 Feb 2010 08:28:04 -0500 Original-Received: from ttn by ambire.localdomain with local (Exim 4.63) (envelope-from ) id 1Nem3u-00022z-GO for guile-user@gnu.org; Tue, 09 Feb 2010 10:07:14 +0100 In-Reply-To: (Andy Wingo's message of "Mon, 08 Feb 2010 12:11:17 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-Greylist: delayed 1222 seconds by postgrey-1.27 at monty-python; Tue, 09 Feb 2010 08:28:03 EST X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:7630 Archived-At: () Andy Wingo () 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 }