[43902] trunk/base/src/pextlib1.0/Pextlib.c

perry at macports.org perry at macports.org
Tue Dec 16 16:57:03 PST 2008


Revision: 43902
          http://trac.macports.org/changeset/43902
Author:   perry at macports.org
Date:     2008-12-16 16:57:03 -0800 (Tue, 16 Dec 2008)
Log Message:
-----------
pextlib1.0/Pextlib.c - Added mkdtemp.  (Addresses Ticket #17181)

Modified Paths:
--------------
    trunk/base/src/pextlib1.0/Pextlib.c

Modified: trunk/base/src/pextlib1.0/Pextlib.c
===================================================================
--- trunk/base/src/pextlib1.0/Pextlib.c	2008-12-16 23:51:43 UTC (rev 43901)
+++ trunk/base/src/pextlib1.0/Pextlib.c	2008-12-17 00:57:03 UTC (rev 43902)
@@ -798,6 +798,32 @@
 	return TCL_OK;
 }
 
+int MkdtempCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+	char *template, *sp;
+	Tcl_Obj *tcl_result;
+
+	if (objc != 2) {
+		Tcl_WrongNumArgs(interp, 1, objv, "template");
+		return TCL_ERROR;
+	}
+
+	template = strdup(Tcl_GetString(objv[1]));
+	if (template == NULL)
+		return TCL_ERROR;
+
+	if ((sp = mkdtemp(template)) == NULL) {
+		Tcl_AppendResult(interp, "mkdtemp failed: ", strerror(errno), NULL);
+		free(template);
+		return TCL_ERROR;
+	}
+
+	tcl_result = Tcl_NewStringObj(sp, -1);
+	Tcl_SetObjResult(interp, tcl_result);
+	free(template);
+	return TCL_OK;
+}
+
 int MktempCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
 	char *template, *sp;
@@ -1210,6 +1236,7 @@
 	Tcl_CreateObjCommand(interp, "strsed", StrsedCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "mkstemp", MkstempCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "mktemp", MktempCmd, NULL, NULL);
+	Tcl_CreateObjCommand(interp, "mkdtemp", MkdtempCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "existsuser", ExistsuserCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "existsgroup", ExistsgroupCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "nextuid", NextuidCmd, NULL, NULL);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20081216/1647c1a0/attachment-0001.html>


More information about the macports-changes mailing list