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";

{{
// Definitions for function stat
%define FILE_SOURCE_PERMS   0x1000;                             // Copy source file's permissions

// Definitions for set file permissions
%define USETID                  0x8000;                                 /* Set user id */
%define UREAD                   0x0400;                                 /* Read by user */
%define UWRITE                  0x0200;                                 /* Write by user */
%define UEXECUTE                0x0100;                                 /* Execute by user */

%define GSETID                  0x4000;                                 /* Set group id */
%define GREAD                   0x0040;                                 /* Read by group */
%define GWRITE                  0x0020;                                 /* Write by group */
%define GEXECUTE            0x0010;                                     /* Execute by group */

%define WSTICKY                 0x2000;                                 /* Sticky bit */
%define WREAD                   0x0004;                                 /* Read by others */
%define WWRITE                  0x0002;                                 /* Write by others */
%define WEXECUTE                0x0001;                                 /* Execute by others */

%define OS_DEFAULT              0x0FFF;                                 /* use OS's default permissions */

}}

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>