Go to main content

append

is used to copy/append file

APPEND

NAME

append - is used to copy/append file

SYNOPSIS

append([permissions:integer, owner:"rwx", group:"rwx", other:"rwx",][append:true|false,create:true|false,error:variable]"src filename", "dst filename")

append([permissions:integer, owner:"rwx", group:"rwx", other:"rwx",][append:true|false,create:true|false,error:variable]src:"src filename", dst:"dst filename")

DESCRIPTION

This function is used to copy a file and append it in a destination file. "Append" means to join or to add something at the end: hence, it concatenates files.

If the argument to "append" is true and if the destination exists, then it will append to the file.

If the argument to "create" is false and if the destination file does not exist, the file won't be created.

File are copied from the root of the file system.

The root of the filesystem is defined in the configuration file. See ExtensoConfig for more information.

The permissions of the destination file can be specified using permissions:

permissions:UREAD|UWRITE

or other permissions can be added using owner, group or other.

group:"rw" will add read and write permission 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={_{ copy("a", "b"); }}. return .*open src.*));
res={_{ copy(create:false, "c1", "b"); }}. return .*stat dst .*
res={_{ copy(append:false, "/tests/c1", "/tests/c2"); size("/tests/c1") == size("/tests/c2"); }}. return res=true.
res={_{ copy(src:"/tests/c1", "/tests/c2"); 2*size("/tests/c1") == size("/tests/c2");}}. return res=true.
res={_{ copy(src:"/tests/c1", dst:"/tests/c2"); 3*size("/tests/c1") == size("/tests/c2");}}. return res=true.
res={_{ copy(append:false,src:"/tests/c1", dst:"/tests/c2"); size("/tests/c1") == size("/tests/c2");}}. return res=true.
res={_{ copy(create:false,src:"/tests/c1", dst:"/tests/c3"); size("/tests/c1") == size("/tests/c2");}}. return .*stat dst.*

SEE ALSO

{{ include("includes/files.sn") }}

AUTHOR

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

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

Edit

© 2024 extenso Inc. All rights reserved.