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

  1. #include <tcl.h>
  2.  
  3. static int
  4. CopyCmd(ClientData clientData, Tcl_Interp *interp,
  5. int objc, Tcl_Obj *const objv[])
  6. {
  7. Tcl_Obj *errObj = NULL;
  8. if (objc != 3) {
  9. Tcl_WrongNumArgs(interp, 1, objv, "source dest");
  10. return TCL_ERROR;
  11. }
  12.  
  13. if (Tcl_FSCopyDirectory (objv[1], objv[2], &errObj) != TCL_OK) {
  14. Tcl_SetObjResult(interp, errObj);
  15. return TCL_ERROR;
  16. }
  17. return TCL_OK;
  18. }
  19.  
  20.  
  21. /**
  22. * main function that manages tcl calls
  23. *
  24. * @param Tcl_Interp @link http://www.tcl.tk/man/tcl8.4/TclLib/Interp.htm
  25. */
  26. int DLLEXPORT
  27. Cp_Init(Tcl_Interp *interp)
  28. {
  29. #ifdef USE_TCL_STUBS
  30. if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
  31. return TCL_ERROR;
  32. }
  33. #endif
  34.  
  35. Tcl_CreateObjCommand (interp, "cp", CopyCmd, NULL, NULL);
  36. return Tcl_PkgProvide(interp, "Cp", "1.0");
  37. }