Posted to tcl by patthoyts at Sun May 25 16:15:04 GMT 2008view pretty

#include <tcl.h>

static int 
CopyCmd(ClientData clientData, Tcl_Interp *interp,
        int objc, Tcl_Obj *const objv[])
{
    Tcl_Obj *errObj = NULL;
    if (objc != 3) {
        Tcl_WrongNumArgs(interp, 1, objv, "source dest");
        return TCL_ERROR;
    }
    
    if (Tcl_FSCopyDirectory (objv[1], objv[2], &errObj) != TCL_OK) {
        Tcl_SetObjResult(interp, errObj);
        return TCL_ERROR;
    }
    return TCL_OK;
}


/**
 *        main function that manages tcl calls
 *
 *        @param Tcl_Interp @link http://www.tcl.tk/man/tcl8.4/TclLib/Interp.htm
 */
int DLLEXPORT
Cp_Init(Tcl_Interp *interp)
{
#ifdef USE_TCL_STUBS
    if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
        return TCL_ERROR;
    }
#endif

    Tcl_CreateObjCommand (interp, "cp", CopyCmd, NULL, NULL);
    return Tcl_PkgProvide(interp, "Cp", "1.0");
}