Ellié Computing Home Page
My Shopping Cart

Your shopping cart is empty

Display Cart

Call us at +1 586 62 ELLIE / +1 586 62 35543 Office Closed
sales@elliecomputing.com - Contact us


VFS object

 

 

VFS global object.

Syntax

A VFS global object is created for you and only this object can exist in the application. It is named VFS and is globally accessible.

Parameters

none.

Property Of

global name space.

Implemented In

ECMerge 2.1

Description

 The VFS object let you realize a few basic operations on files and folders currently. Files and folders are pointed to by URL objects.

Properties

Property Description
kRead Integer. Used to indicate that a file is open for reading only
kWrite Integer. Used to indicate that a file is open for writing only
kReadWrite Integer. Used to indicate that a file is open for both reading and wirting
kAppend Integer. Used to indicate that a file is open to write at end
kCreateAlways Integer. Used to indicate that a file is always opened empty, ignoring its presence and/or old content
kCreateNew Integer. Used to indicate that a file is only added
kOpenExisting Integer. Used to indicate that a file is only opened (i.e. not created)
kOpenAlways Integer. Used to indicate that a file is opened if it is there, created if it was not
kTruncateExisting Integer. Used to indicate that a file is only opened, but emptied at once
kShareRead Integer. Used to indicate that a file is open, allowing others to read at the same time
kShareWrite Integer. Used to indicate that a file is open, allowing others to write at the same time
kShareAll Integer. Used to indicate that a file is open ,allowing all accesses
kShareNone Integer. Used to indicate that a file is open, but none else should access the file
kTemporary Integer. Used to indicate that a file is open as a temporary file
kAutoAbort Integer. Used to indicate that a file is open, but it should be deleted unless a validation occurs successfuly
kFileAttrReadWrite Ineger. Used to indicate that the item can be written to (by current user on Unix, by any user with appropriate rights else)
kFileAttrHidden Integer. Used to indicate that a file as the hidden attribute
kFileAttrSystem Integer. Used to indicate that a file as the system attribute
kFileAttrDirectory Integer. Used to indicate that the item is a directory
kFileAttrArchive Integer. Used to indicate that a file as the archive attribute
kFileAttrNormal Integer. Used to indicate a normal file
kFileAttrTemporary Integer. Used to indicate that a file as the temporary attribute
kFileAttrCompressed Integer. Used to indicate that a file/directory is compressed
kFileAttrEncrypted Integer. Used to indicate that the file/directory is encrypted
kFileAttrSymLink Integer. Used to indicate that the file/directory is a symbolic link.
kFileAttrUnixModesMultiplier Integer. Multiply Unix modes by this number to represent them in a attrib bit-mask.

 

Methods

attrib
dir
get_temporary_dir_url
get_temporary_file_name
get_temporary_file_url
load_text
save_text
set_dates
stat

Examples

see functions samples.

See Also 

  URL object.

Method attrib

Syntax

function attrib ( url, attributes_to_set, attributes_values )

Parameters

url. URL object. URL toward the directory to list
attributes_to_set. UInt32. Bit mask of files attributes to set choosen from kFilesAttr??? values.
attributes_values. UInt32. Bit mask of files attributes values choosen from kFilesAttr??? values.

Method Of

VFS object.

Implemented In

ECMerge 2.1

Description

Modifies the attributes of a file. Attributes which are not present in the parameter attributes_to_set are not affected by attrib execution. 

Examples

Example 1.

Mark a file as read-write:

VFS.attrib ("c:\\myfile.txt", VFS.kFileAttrReadWrite, VFS.kFileAttrReadWrite);

See Also 

URL object,   VFS object, VFS.Metadata object

Method dir

Syntax

function dir ( url, re )
returns an Array of VFS.Metadata objects.

Parameters

url. URL object. URL toward the directory to list
re. RegExp object. Only entries matching this regular expression are returned. If omitted, all entires are returned

Method Of

VFS object.

Implemented In

ECMerge 2.1

Description

Lists the directory designed by url and returns the entries as an Array of metadata.

Examples

Example 1.

Dumps as XML the metadata of all the elements under the root of the file system:

var metadata_array = VFS.dir ("/");
log ( metadata_array.join ( ) );

See Also 

URL object,   VFS object, VFS.Metadata object

Method get_temporary_dir_url

Syntax

function get_temporary_dir_url ( with_ext )
returns a String

Parameters

with_ext. If defined, the directory's name will end with this string

Method Of

VFS object.

Implemented In

ECMerge 2.2

Description

Returns the name for a temporary file. Usually an empty file is created with this name during the execution of this call, to avoid another call returning the same value.

Examples

Example 1.

Makes a temporay directory and save a file called myfile.txt within:

var my_temp_dir = VFS.get_temporary_dir_url ();
VFS.save_text (my_temp_dir.compose('myfile.txt'), 'the file content');

See Also 

get_temporary_file_name method,  get_ temporary_file_url method,   VFS object

Method get_temporary_file_name

Syntax

function get_temporary_file_name ( )
returns a String

Parameters

none.

Method Of

VFS object.

Implemented In

ECMerge 2.1
Deprecated. Supersedeed by get_temporary_file_url and get_temporary_dir_url since ECMerge 2.2

Description

Returns the name for a temporary file. Usually an empty file is created with this name during the execution of this call, to avoid another call returning the same value.
NB: This method is deprecated because it had to let the empty file there to avoid synchronization problems, but the empty file was never deleted. Use get_temporary_file_url and get_temporary_dir_url instead.

Examples

Example 1.

Prints 10 different temporary file names:

for (var idxtfn=0; idxtfn<10; ++idxtfn)
    log ( VFS.get_temporary_file_name () );

See Also 

  VFS object

Method get_temporary_file_url

Syntax

 

function get_temporary_file_url ( with_ext )
returns a String

Parameters

with_ext. If defined, the file's name will end with this string

Method Of

VFS object.

Implemented In

ECMerge 2.2

Description

Returns the name for a temporary file. Usually an empty file is created with this name during the execution of this call, to avoid another call returning the same value.

Examples

Example 1.

Prints 10 different temporary file names with the '.txt' extension:

for (var idxtfn=0; idxtfn<10; ++idxtfn)
    log ( VFS.get_temporary_file_url ('.txt') );

See Also 

get_temporary_file_name method,   get_temporary_dir_url method,   VFS object

Method load_text

Syntax

function load_text (url, encoding, detect, at_most)
returns a String

Parameters

url. URL object. URL pointing to the text file to read.
encoding. Encoding string. Encoding to use (see 'detect'). If undefined or omitted, load_text uses default system encoding.
detect. Boolean. True when signatures detection is enabled (currently Unicode signatures), hence encoding is a 'default'. False to ignore signatures, therefore, encoding is then always used. If undefined or omitted, true is assumed.
at_most. Integer. Number of bytes which you accept to read from the file. If undefined or omitted, the whole file is read.

Method Of

VFS object.

Implemented In

ECMerge 2.1

Description

Reads a text file and returns its content as a string.

Examples

Example 1.

Displays a message with the content of a file:

alert ( VFS.load_text ( "/etc/hosts" ) );

See Also 

  VFS object

Method save_text

Syntax

function save_text ( url, text, encoding, save_signature, creation_flags)

Parameters

url. URL object. URL pointing where to save the text.
text. String. Text to save
encoding. Encoding string. Encoding to use to save the text. If undefined or omitted, default system encoding is used.
save_signature. Boolean. True when the appropriate signature for encoding should be written. If undefined or omitted, true is assumed.
creation_flags. Integer. A bitwise-OR of VFS.k??? constants. If undefined or omitted, VFS.kCreateNew|VFS.kReadWrite|VFS.kShareNone is assumed.

Method Of

VFS object.

Implemented In

ECMerge 2.1

Description

Saves a text to a URL location, in a given encoding.

Examples

Example 1.

Saves a text file:

var text = "hello world!";
VFS.save_text ("/tmp/mytest.txt", text, "UTF-8", true, VFS.kCreateAlways|VFS.kWrite);

See Also 

  VFS object, URL object

Method set_dates

Syntax

function set_dates ( url, last_access, last_update, creation)

Parameters

url. URL object. URL pointing to the file.
last_access. Date. Last access date to item. If undefined or omitted, this date is not set for the file
last_update. Date. Date of last modification of the file. If undefined or omitted, this date is not set for the file
creation. Date. Date of creation of the file. If undefined or omitted, this date is not set for the file

Method Of

VFS object.

Implemented In

ECMerge 2.2

Description

Set the dates for a file. Most file system supports three dates: the creation date, the last modification date and last access date, this function let you set these dates with arbitrary values.
Note that some file systems store only a "last_update" date. Each file system store dates with a specific precision, some use 2-seconds precision (FAT), some use real tight precision (below the microsecond, NTFS). JavaScript Date objects have a built-in precision at the millisecond, you might thus be unable to repesent the dates of NTFS with exactness.

Examples

Example 1.

Set all the dates to current date for imaginary file "/tmp/mytest.txt" :

var my_date = new Date();
VFS.set_dates ("/tmp/mytest.txt", my_date, my_date, my_date);

Example 2.

Implements the famous "touch" function in ECMerge :

function touch (url) {
    VFS.set_dates (url, undefined, new Date());
}

See Also 

  VFS object, URL object

Method stat

Syntax

function stat ( url )
returns a VFS.Metadata object

Parameters

url. URL object. URL pointing to the file.

Method Of

VFS object.

Implemented In

ECMerge 2.2.109

Description

Returns the metadata for a single item pointed to by a URL. 

Examples

Example 1.

Displays the last update time for a FTP file:

alert (VFS.stat("ftp://myserver.domain.com/a-file.txt"));

See Also 

  VFS object, URL object