System object

Methods of this object are not always available to the script - they depend on feature parameters of VM creation.

Constants

IS_READONLY
- int, scanFiles callback/attributes, file/dir is readonly.
IS_DIR
- int, scanFiles callback/attributes, file is directory(folder).
IS_HIDDEN
- int, scanFiles callback/attributes, file/dir is marked as hidden.
IS_SYSTEM
- int, scanFiles callback/attributes, file/dir is marked as internal for the system.
MOBILE_OS
- true for the mosciter that is running on mobile platform, false otherwise.
DESKTOP_OS
- true for the sciter running on desktop PC/platform, false otherwise.
OS
- symbol, on Windows it is one of these:
PLATFORM
- symbol, one of these:
EOL
- string, platform specific end-of-line sequence, on Windows "\r\n" and on others "\n". 

Properties

language
The abbreviated name of the language, ISO Standard 639 names.
country
Country/region name, based on ISO Standard 3166.
ticks
High resolution timer. Return an integer representing the time elapsed since the engine started in milliseconds

Methods

scanFiles

( path:string [, callback:function] ) :integer

Function calls callback function for each entry found in directory defined by the path. Path can contain wildcards like ? or *. Function returns number of entries scanned.

If callback is ommited then function just returns number of items satisfying path condition. In this form the scan can be used for testing of some file existence as an example.

Callback function shall accept two parameters:

function callback( filename: string, attributes: integer ): bool

where filename is an name of the file and attributes is an integer - OR-ed combination of IS_*** flags. Callback function shall return true if further scanning needed and false to stop enumeration.

home
([relpath:string]) returns: string

Returns home folder of the application - folder where sciter started from. If relpath is some string then it will be appended to the return value. Use this if you need to find fully qualified file name residing in sciter folder or subfolder.

path
(system-folder: symbol [,relpath:string]) returns: string

Returns path of one of the system folders. system-folder here is one of:

exec
(exe-path: string [,arg1:string ... argN: string]) returns: integer

Starts executable asynchronously passing optional command line parameters. The method does not wait for executable to complete.

Retuns 0 if executable has started successfully and C runtime errno variable code otherwise (EACCES, ENOTDIR, etc.).

dir
( path:string , callback:function[, wantStats: true | false] ) : true | false

Extended version of scanFiles function. The callback function accepts three parameters:

function callback( fileName: string, fileType: symbol, fileStats: object ) where:

stat
sync.stat
( path: string ) : promise or FileStats

Asynchronous method that returns promise. Can be used as:

System.stat("d:/test.txt").then( function(stats) {...} );
Or in asynchronous functions as:
async function checkStats() {
   var stats = await System.stat("d:/test.txt");
   ...
}
unlink
sync.unlink
( path: string ) : promise (true | error code on failure)

Asynchronously or synchronously removes a file or symbolic link.

rmdir
sync.rmdir
( path: string ) : promise (true | error code on failure)

Removes directory (a.k.a. folder). Directory must be empty. The function calls rmdir

mkdir
sync.mkdir
( path: string : promise (true | error code on failure)

Creates directory (a.k.a. folder). The function calls mkdir

rename
sync.rename
( oldPath: string, newPath: string : promise (true | error code on failure)

Asynchronously rename file at oldPath to the pathname provided as newPath. In the case that newPath already exists, it will be overwritten. If there is a directory at newPath, an error will be raised instead.

copyFile
sync.copyFile
(  srcPath: string, dstPath:  string [,#no-overwrite] : promise (true | error code on failure)

Asynchronously copies src to dst. By default, dst is overwritten if it already exists. Sciter makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Sciter will attempt to remove the destination. If #no-overwrite parameter is provided the operation will fail if something is on dstPath already. 

utimes
sync.utimes
( path: string, atime: Date, mtime: Date : promise (true | error code on failure)

Change the file system timestamps of the object referenced by path. 

chmod
sync.chmod
( path: string, mode: integer : promise (true | error code on failure)

Changes file mode bits. The function calls chmod system function.

watch
( path: string : FileMonitor

Creates FileMonitor object that will receive change notifications on a file or folder content. The only public method of FileMonitor is close() - stop monitoring and dispose the monitor. The FileMonitor instance supports change and rename events:

var watcher = null;  
if( watcher ) 
    watcher.close();
var path = ...;
// create file monitor and subscribe to events:
that.watcher = System.watch(path)
          << event change (path) { ... change detected ... } 
          << event rename (path) { ... change detected ... };