How can copy or move files by my AI plugin in Leopard??

Advertisement
How can copy or move files by my AI plugin in Leopard??
Thanks!
hanyang
Advertisement

Replay

You can use "execve". This example will copy /tmp/file1 to /tmp/file2<br /><br />#include <stdio.h><br />#include <sys/types.h><br />#include <unistd.h><br /><br />pid_t forkPid;<br /><br />char *childargs[] = { "cp", "/tmp/file1", "/tmp/file2", 0 };<br /><br />if( ( forkPid = fork() ) == 0 ) {<br /><br />  execve( "/bin/cp", childargs, NULL );<br /><br />} else if( forkPid > 0 ) {<br /><br />  printf( "Success!" );<br /><br />} else {<br /><br />  printf( "Can't fork" );<br /><br />}<br /><br />For more information, man execve.