Changeset 43902


Ignore:
Timestamp:
Dec 17, 2008, 12:57:03 AM (12 years ago)
Author:
perry@…
Message:

pextlib1.0/Pextlib.c - Added mkdtemp. (Addresses Ticket #17181)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/pextlib1.0/Pextlib.c

    r42061 r43902  
    799799}
    800800
     801int MkdtempCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
     802{
     803        char *template, *sp;
     804        Tcl_Obj *tcl_result;
     805
     806        if (objc != 2) {
     807                Tcl_WrongNumArgs(interp, 1, objv, "template");
     808                return TCL_ERROR;
     809        }
     810
     811        template = strdup(Tcl_GetString(objv[1]));
     812        if (template == NULL)
     813                return TCL_ERROR;
     814
     815        if ((sp = mkdtemp(template)) == NULL) {
     816                Tcl_AppendResult(interp, "mkdtemp failed: ", strerror(errno), NULL);
     817                free(template);
     818                return TCL_ERROR;
     819        }
     820
     821        tcl_result = Tcl_NewStringObj(sp, -1);
     822        Tcl_SetObjResult(interp, tcl_result);
     823        free(template);
     824        return TCL_OK;
     825}
     826
    801827int MktempCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
    802828{
     
    12111237        Tcl_CreateObjCommand(interp, "mkstemp", MkstempCmd, NULL, NULL);
    12121238        Tcl_CreateObjCommand(interp, "mktemp", MktempCmd, NULL, NULL);
     1239        Tcl_CreateObjCommand(interp, "mkdtemp", MkdtempCmd, NULL, NULL);
    12131240        Tcl_CreateObjCommand(interp, "existsuser", ExistsuserCmd, NULL, NULL);
    12141241        Tcl_CreateObjCommand(interp, "existsgroup", ExistsgroupCmd, NULL, NULL);
Note: See TracChangeset for help on using the changeset viewer.