Skip to main content
Known Participant
April 9, 2008
Question

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

  • April 9, 2008
  • 3 replies
  • 803 views
How can copy or move files by my AI plugin in Leopard??

Thanks!

hanyang
This topic has been closed for replies.

3 replies

3DTOPO
Inspiring
April 9, 2008
You're welcome. It should work - I tested it on Leopard. My print statements are not accurate. If you have any questions, just let me know.
jdyyzAuthor
Known Participant
April 9, 2008
Hi Jeshua,

Thanks for your reply and sample code!

I'll try this.
3DTOPO
Inspiring
April 9, 2008
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.