function

cp . files . sncode

VERSIONlatest Copy a file.

CP

NAME

cp - Copies a file.

DESCRIPTION

This function is used to copy a file A to a file B.

The permissions of the destination file can be specified using:

permissions:UREAD|UWRITE

 Uread and Uwrite are predefined. Other permissions can be added using owner, group or other. Uread stands for User Read. The user to whom the file belongs can read it. 

group:"rw" will add read and write permissions to the group of the directory.

Include file "/includes/extenso.sn" contains definitions for permissions:

%include "/includes/extenso.sn";


EXAMPLES

Note: In the followings examples, the _ between the { should be removed to make it work.

res={_{ cp("toto.txt"); }} return Function cp required 2 argument
res={_{ cp("toto.txt","tata.txt"); }} return Can't rename file
res={_{
         void generate(file:"/tmp/toto.txt",template:"/tests/sample.sn");
         -e "/tmp/tata.txt";
         -e "/tmp/toto.txt";
         -e "/tmp/titi.txt";
         cp("/tmp/toto.txt","/tmp/tata.txt","/tmp/toto.txt","/tmp/titi.txt");
         -e "/tmp/tata.txt";
         -e "/tmp/toto.txt";
         -e "/tmp/titi.txt";
         remove("/tmp/tata.txt","/tmp/toto.txt","/tmp/titi.txt");
    }} return res=falsetruefalsetruetruetrue.

res={_{
         void generate(file:"/tmp/toto.txt",template:"/tests/sample.sn");
         cp("/tmp/toto.txt","/tmp/tata.txt");
         a = stat("/tmp/tata.txt");
         printf(" %x",a.fileperms);
         remove("/tmp/tata.txt");
         cp(owner:"rx",group:"w",other:"x","/tmp/toto.txt","/tmp/tata.txt");
         a = stat("/tmp/tata.txt");
         printf(" %x",a.fileperms);
         remove("/tmp/tata.txt","/tmp/toto.txt");
     }} return res= 644 501.

AUTHOR

Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>