Goto main content


Open a file



open - Open a file


open([permissions:integer, owner:"rwx", group:"rwx", other:"rwx",][read:bool,write:bool,append:true|false,create:true|false,error:variable,stdin:bool]"src filename")

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


This function is used to open a file for reading or writing.

The function return a file descriptor use by close, getline, getchar, seek and ungetchar.

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 open from the root of the file system.

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

If parameter stdin(standard input standard idiom) is true, than the function will open STDIN for input instead of a file. This is most usefull with the program sncode as in:

ct = open(stdin:true);
c = getline(ct);
all_line = "";
while c do
    all_line .+= c;
    c = getline(ct);
email(from:"", to:"", subject:"Receive email", message:all_line);

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


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/" contains definitions for permissions:

%include "/includes/";

// 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 */



    ct = open(read:true,file:"/html/post1.html"); 


{{ include("includes/") }}


Written by Pierre Laplante, <>


1.0 2015-12-28 21:24:14

1.1 2017-03-14 Add stdin to open. Start at version 5.80


© 2024 extenso Inc. All rights reserved.